How to disable Laravel 5 log file?

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.


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;

Maximum Daily Log Files

When using the daily log mode, Laravel will only retain five days of log files by default. If you want to adjust the number of retained files, you may add a log_max_files configuration value to your app configuration file:

config >> app.php

'log_max_files' => 30

For more : https://laravel.com/docs/5.5/errors


I know that this a bit old, but:

In config/logging.php: In channels section add these:

'none' => [
    'driver' => 'monolog',
    'handler' => \Monolog\Handler\NullHandler::class,
],

Then update your .env file to use this logger:

LOG_CHANNEL=none

And everything should work just fine.