1

在我的 Symfony 3.4 中。应用程序我已经配置了一个自定义记录器:

monolog:
  handlers:
    my_channel:
      level: debug
      type: stream
      path: '%kernel.logs_dir%/my_channel.log'
      max_files: 10
      channels: [my_channel]

当我在我的代码中使用这个记录器时,我已经正确注入了通道“my_channel”。

 $this->logger->error('error message', $data = ['my context here']);

在屏幕上,我得到正确显示的 $data 信息:

09:00:08 ERROR     [my_channel] error message ["my context here"]

但不在我的日志中,上下文为空:

09:00:08 ERROR     [my_channel] error message []

问题:如何将上下文也记录到我的日志文件中?

4

1 回答 1

5

原因是上下文数据不是 UTF-8 编码的。

于 2017-12-01T10:46:06.090 回答