Laravel 的日志级别,有什么不同?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44819531/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel log level, how is different?
提问by My Lê
I can see few log options in Laravel 5.4 such as
我可以在 Laravel 5.4 中看到几个日志选项,例如
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.
我可以在更改日志级别app.php
在'log_level' => env('APP_LOG_LEVEL', 'debug'),
任何种类的水平我想要的。
But I was wondering that, what is different? What kind of log has been wirtten when one of critical, alert, emergency
is selected?
但我想知道,有什么不同?critical, alert, emergency
选择其中之一时写入了什么样的日志?
采纳答案by Kris Roofe
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,
你可以参考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.
使用 Monolog 时,日志消息可能具有不同的严重性级别。默认情况下,Laravel 将所有日志级别写入存储。但是,在您的生产环境中,您可能希望通过在 app.php 配置文件中添加 log_level 选项来配置应记录的最低严重性。
配置此选项后,Laravel 将记录大于或等于指定严重性的所有级别。例如,默认的 log_level 错误将记录错误、严重、警报和紧急消息:
'log_level' => env('APP_LOG_LEVEL', 'error'),
Monolog 识别以下严重性级别 - 从最不严重到最严重:调试、信息、通知、警告、错误、严重、警报、紧急情况。