我正在使用 laravel monolog 来分隔信息、警告和错误日志
友情链接 : https://laracasts.com/discuss/channels/general-discussion/advance-logging-with-laravel-and-monolog
我已经复制了,它正在工作。
我唯一的问题是关于错误日志记录,
当我们查看每日错误日志时,它看起来不错,并且每个数字都换行例如
Stack trace:
#0 'Error exception with message of undefined'
#1 .../location line (44)
但自定义日志记录不会用这些数字换行。这是正常的还是我在配置中做错了什么?
我尝试使用格式化程序,但仍然不起作用
$logFormat = "%datetime% [%level_name%] (%channel%): %message% %context% %extra%'n";
$formatter = new LineFormatter($logFormat);
$errorStreamHandler->setFormatter($formatter);
$infoStreamHandler->setFormatter($formatter);
错误仍然如下所示,没有任何换行符
Stack trace: #0 'Error exception with message of undefined' #1 .../location line (44)
是否有解决方法可以在每个数字行后换行
谢谢
检查 LineFormatter 文档 (https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php),并在创建新的格式化程序时将 allowInlineLineLinesBreak 设置为 true,如下所示:
$formatter = new LineFormatter($logFormat, null, true);