My Laravel 5 website is working in a shared host with 1 GB disk space. But now I have about 100 MB log file. How I can disable log file in Laravel 5 ?
If you're having a space problem you can try using daily logs, it will automatically keep last X days of log (default 5). You can see it in Errors & Logging - Log Storage. Otherwise you can simply remove the storage/logs/laravel. log file or make a command to do so (like php artisane log:clear ).
By default, Laravel is configured to create a single log file for your application, and this file is stored in app/storage/logs/laravel. log .
You can see the generated log entries in storage/logs/laravel. log file.
The Laravel logging facilities provide a simple layer on top of the powerful Monolog library. By default, Laravel is configured to create daily log files for your application which are stored in the storage/logs directory. You may write information to the log like so: Log::info('This is some useful information.
In order to completely disable logging you'll need to overwrite the default log handlers that are set by Laravel. You can easily do this with
$nullLogger = new NullHandler(); \Log::getMonolog()->setHandlers(array($nullLogger));
You need to call as early as possible, before request is processed, e.g. you could do that in your bootstrap/app.php:
$app->configureMonologUsing(function($monolog) { $nullLogger = new \Monolog\Handler\NullHandler(); $monolog->setHandlers(array($nullLogger)); }); return $app;
If your log is very large then either you are logging a lot or your application is throwing a lot of errors. You should first examine the log and see if you can reduce data being written.
You can also switch to daily logging and then have a job to delete old log files.
The next thing to do would be to update your logging configuration to daily instead of the default single in config/app.php
Laravel will handle rotating the file daily and deleting old log files after 5 days, or the value of the app.max_log_files
if you need more kept.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With