Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel log level, how is different?

I can see few log options in Laravel 5.4 such as

Log::emergency($message);
Log::alert($message);
Log::critical($message);
Log::error($message);
Log::warning($message);
Log::notice($message);
Log::info($message);
Log::debug($message);

And I can change log level in app.php at 'log_level' => env('APP_LOG_LEVEL', 'debug'), to any kind of level I want.

But I was wondering that, what is different? What kind of log has been wirtten when one of critical, alert, emergency is selected?

like image 458
My Lê Avatar asked Jun 29 '17 08:06

My Lê


People also ask

What are the Laravel log levels?

The logger provides the eight logging levels defined in RFC 5424: emergency, alert, critical, error, warning, notice, info and debug.

Which logging level is best?

Higher values indicate higher priorities. As such, a rule might look for Error and Fatal messages by looking for values greater than or equal to 40,000 (Level>=40000). Inherit the level from the parent logger.

Which log level should be used in production?

Logging levels are usually considered to be in order of importance: turn on "unimportant" levels in development ( trace , debug and the like), but enable only the "most important" levels ( warning , error , etc.) in production, where resources like CPU time and disk space are precious.


1 Answers

When you set the log level, only the level big or equal than the setted level will be logged.

You can refer to the laravel doc log-severity-levels,

When using Monolog, log messages may have different levels of severity. By default, Laravel writes all log levels to storage. However, in your production environment, you may wish to configure the minimum severity that should be logged by adding the log_level option to your app.php configuration file.

Once this option has been configured, 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:

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

Monolog recognizes the following severity levels - from least severe to most severe: debug, info, notice, warning, error, critical, alert, emergency.

like image 66
LF00 Avatar answered Sep 27 '22 21:09

LF00