Ad

How To Disable Laravel 5 Log File?

- 1 answer

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 ?

Ad

Answer

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;
Ad
source: stackoverflow.com
Ad