Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tptompkins's avatar

How to change log levels?

In the Laravel 5.2 documentation it states the following:

By default, Laravel writes all log levels. In your production environment, you may wish to configure the default log level by adding the log_level option to your app.php configuration file. Laravel will then log all levels greater than or equal to the specified severity level. For example, a default log_level of error will log error, critical, alert, and emergency messages:

'log_level' => env('APP_LOG_LEVEL', 'debug'),

I've added the following to my app.php file:

'log_level' => env('APP_LOG_LEVEL', 'error'),

I also added the following to my .env file:

APP_LOG_LEVEL=error

After doing this, it still logs all levels when I'm expecting it to just log errors and above. Am I missing something? Is there something special that needs to be done to be able to specify log levels based on environment config?

0 likes
7 replies
Konsole's avatar

@tptompkins Laravel will log all levels greater than or equal to the specified severity. For example, a default log_level of error will log error, critical, alert, and emergency messages. Laravel uses monolog for logging. Monolog recognizes the following severity levels - from least severe to most severe: debug, info, notice, warning, error, critical, alert, emergency.

In your case Laravel will not log debug, info, notice, warning level messages and will log error, critical, alert, and emergency. You can find more information here.

1 like
tptompkins's avatar

Thanks @Konsole and that's exactly how I interpreted it as well. But the problem is, that isn't how it's working. If I configure it to log at the "error" level, it still continues to log info and debug messages as well when it shouldn't according to your interpretation of the docs. I feel like there might be a bug here.

Konsole's avatar

@tptompkins Looks like you changed the log level directly in your app.php.You must have APP_LOG_LEVEL set to debug in you .env file. Check if you have APP_LOG_LEVEL=debug in your .env. If yes, you should change it to error and leave app.php as it is.

tptompkins's avatar

Nope, my .env file has APP_LOG_LEVEL=error just like I mentioned in my original post.

Also, if I do a full text search across my entire Laravel 5.2 project for log_level, it isn't mentioned anywhere in the code other than in my config/app.php file which is the line I personally added to the config based on the docs. This leads me to believe that the docs are wrong and that log_level isn't being used anywhere in the Laravel code base. Can anyone confirm?

Snapey's avatar

When you said

I've added the following to my app.php file:

'log_level' => env('APP_LOG_LEVEL', 'error'),

Do you mean that you changed the existing line? Just checking that you have not got this line twice?

tptompkins's avatar
tptompkins
OP
Best Answer
Level 7

Hi @Snapey - no, I mean that I added that line because that line didn't exist in my original Spark installation. I installed Spark with 5.2 back in April and that line must not have existed in that distribution for some reason, but I can see that it's now included in the latest 5.2 release. Thinking that it might have been an issue with an earlier 5.2 release, I did a composer update to update my installation to the latest 5.2.45 version. After updating with composer, I'm happy to say that everything is working as expected now :)

Please or to participate in this conversation.