【发布时间】:2018-09-26 08:56:48
【问题描述】:
是否可以为 syslog 格式化日志?配置系统日志的config.yml:
monolog:
channels: ['auth']
handlers:
auth:
type: syslog
level: debug
facility: local0
channels: [auth]
出现警告时打印的结果行:
Sep 20 15:43:31 api2 [10227]: auth.WARNING: invalid password {"method":"ApiBundle\\Api.....
我想看到的那条线:
Sep 20 15:43:31 api2 auth.WARNING[10227]: invalid password {"method":"ApiBundle\\Api.....
我尝试使用格式化程序,但没有成功:
# config.yml
monolog:
...
handlers:
auth:
...
formatter: monolog.formatter.auth_exception
# services.yml
monolog.formatter.auth_exception:
class: Monolog\Formatter\LineFormatter
arguments:
- "[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
【问题讨论】:
-
你的格式化程序在哪里?你的格式化程序是实现 Monolog\Formatter\FormatterInterface
-
Monolog\Formatter\LineFormatter 是 Monolog 的内置 Formatter
-
@paddel10 这个问题你解决了吗?
-
@nssmart 请在下面查看我的回答。希望这会有所帮助
标签: php symfony syslog monolog