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 ?
-
1maybe interesting? duplicate? [Is there any global configuration option to disable all logging?](http://stackoverflow.com/questions/26321898/disable-logging-in-laravel) – Ryan Vincent Jan 13 '16 at 23:02
7 Answers
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;

- 39,591
- 9
- 98
- 107
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.

- 294
- 1
- 4
- 15

- 637
- 9
- 25
-
2Just a note, full class name of `NullHandler` is `\Monolog\Handler\NullHandler` – Tymur Valiiev Nov 18 '19 at 13:37
-
1does it make a difference if i just use NullHandler::class, or full \Monolog\Handler\NullHandler what releavence is it ? – user3548161 Jun 04 '20 at 05:02
-
-
I'm on Laravel 5.8.38. It does make a difference. When I used `NullHandler` without the fully qualified class name, it didn't work. It still created `laravel.log`, which logged an additional exception, without rendering it in Whoops: `Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): NullHandler must be an instance of Monolog\\Handler\\HandlerInterface at
/Illuminate/Log/LogManager.php:328`. I'll edit the answer accordingly. – Illya Moskvin May 21 '21 at 23:04 -
@IllyaMoskvin just use "use" statement to reference class at the top. Its not laravel-related stuff – Tymur Valiiev May 31 '21 at 15:00
-
2@TymurValiiev Doh, you're right. I knew to look for it, but I still overlooked that the other handlers were referenced via a `use` statement at the top. I should have done the same for `NullHandler`. I'll keep my comment and edit in case it helps someone. – Illya Moskvin Jun 01 '21 at 03:45
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.
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

- 1
- 1

- 1,943
- 14
- 20
for me, the folder 'tmp' in wamp was growing up 15 giga!!
after some research I found out that the reason was the xdebug extension
I simply adjut it not to send debug info, from php.ini
:
xdebug.profiler_enable = 0

- 11,736
- 5
- 20
- 35
You May disable the writing action Log:: is called by commenting the follow line:
Log::useFiles(storage_path().'/logs/laravel.log');
in start/global.php
But first, you should find out why your log file is that big? Second, having some kind of archive function to your file will help as well. Maybe twice a day.
Hope it helps. Good Luck!

- 2,069
- 9
- 38
- 60
-
1My site is under DDos attack, and the log file (50GB) was getting full, which caused my server to stop working. By stopping the writing of this file I was able to concentrate on the solution. – Ever CR Jan 18 '21 at 17:18
Yes definitively you need to edit core laravel file in order not to save log file ..
go to vendor->laravel->framework->src->Illuminate->Log->Writer.php and then comment out all the code within function __call like below.
public function __call($method, $parameters)
{
// if (in_array($method, $this->levels))
// {
// call_user_func_array(array($this, 'fireLogEvent'), array_merge(array($method), $parameters));
// $method = 'add'.ucfirst($method);
// return $this->callMonolog($method, $parameters);
// }
// throw new \BadMethodCallException("Method [$method] does not exist.");
}
You log will never be save.

- 356
- 2
- 8
-
11Editing vendor files is very bad idea. Next composer update/install will loose all your modifications. – ruuter Jan 30 '16 at 14:29
-
2This is a terrible suggestion for the reasons stated in the first comment. – David Barker Sep 20 '17 at 12:13