Laravel Monologue LineFormatter 日期时间模式
Laravel Monolog LineFormatter datetime pattern
我正在尝试在 laravel 中创建自定义日志,并且我正在使用 monlog\LineFormatter class 来格式化我的最终日志
'events' => [
'driver' => 'daily',
'formatter' =>LineFormatter::class,
'formatter_with' => [
'format' => "[%datetime%] %channel%.%level_name%: %context%\n",
],
'path' => storage_path('logs/events.log'),
'level' => 'info'
]
不,我正在日志文件中获取如下日志
[2022-01-27T08:30:33.627980+00:00] local.INFO: {"request-id":"5f9c3819-97b3-4439-87ab-30c58bffd2a5","event_name":"cancel_pending_withdraw","message":"action webhook sent"}
我希望日期时间格式像
[2022-01-27T08:30:33.627980+00:00] ==> [2022-01-27 08:30:33]
如何通过 monolog Lineformatter 更改此格式化程序。
所以我得到了解决方案,最简单的方法如下
'events' => [
'driver' => 'daily',
'formatter' =>LineFormatter::class,
'formatter_with' => [
'format' => "[%datetime%] %channel%.%level_name%: %context%\n",
'dateFormat' => "Y-m-d H:i:s"
],
'path' => storage_path('logs/unique-events.log'),
'level' => 'info'
]
我正在尝试在 laravel 中创建自定义日志,并且我正在使用 monlog\LineFormatter class 来格式化我的最终日志
'events' => [
'driver' => 'daily',
'formatter' =>LineFormatter::class,
'formatter_with' => [
'format' => "[%datetime%] %channel%.%level_name%: %context%\n",
],
'path' => storage_path('logs/events.log'),
'level' => 'info'
]
不,我正在日志文件中获取如下日志
[2022-01-27T08:30:33.627980+00:00] local.INFO: {"request-id":"5f9c3819-97b3-4439-87ab-30c58bffd2a5","event_name":"cancel_pending_withdraw","message":"action webhook sent"}
我希望日期时间格式像
[2022-01-27T08:30:33.627980+00:00] ==> [2022-01-27 08:30:33]
如何通过 monolog Lineformatter 更改此格式化程序。
所以我得到了解决方案,最简单的方法如下
'events' => [
'driver' => 'daily',
'formatter' =>LineFormatter::class,
'formatter_with' => [
'format' => "[%datetime%] %channel%.%level_name%: %context%\n",
'dateFormat' => "Y-m-d H:i:s"
],
'path' => storage_path('logs/unique-events.log'),
'level' => 'info'
]