Reputation: 11691
The laravel documentation indicates on the documentation that "The logger provides the seven logging levels defined in RFC 5424: debug, info, notice, warning, error, critical, and alert."
, but where should this be changed is something that is not provided. Could someone help me understand how this works and where the log level needs to be changed?
Upvotes: 13
Views: 6874
Reputation: 262
We can take Abishek's answer one step further. If we add the log levels to our config files, we can change the log level based on the environment we're in. In config/app.php:
'log_level' => 'debug',
and in config/prod/app.php:
'log_level' => 'warning',
We then change the daily logger to
Log::useDailyFiles(storage_path() . '/logs/' . $logFile, 0, Config::get('app.log_level'));
and we have configurable logging.
Upvotes: 23
Reputation: 11691
Figured it out by looking at the LogWriter Class. Not sure if this is the right approach but, there should be a config on the Laravel App that should set the Laravel Logging Level.
This is what currently needs to be done to change the logging level.
Go to app/start/global.php
(https://github.com/laravel/laravel/blob/master/app/start/global.php#L36) and on Line 36
, you would find the code
Log::useDailyFiles(storage_path().'/logs/'.$logFile);
This needs to be changed to
Log::useDailyFiles(storage_path() . '/logs/' . $logFile, 0, 'error');
The third parameter is where the log level needs to be changed and the following are the log levels that can be used
Hope this helps who ever have been searching for this. I hope there is a simpler way to do this instead of changing the function parameter.
Upvotes: 20