我如何控制 Drupal 8 monolog dblog 日志级别

时间:2021-06-02 20:34:40

标签: drupal-8 monolog

我将 Drupal 8 与 Monolog 模块 (1.3) 一起用于外部日志支持和 Sentry 日志记录,同时保留核心数据库日志记录 (dblog/watchdog)。这一切都有效,除了我找不到控制看门狗日志记录级别的方法(因此我在生产环境中获得了大量调试日志记录)。

这是我的 Monolog 配置 (monolog.services.yml):

parameters:
  monolog.channel_handlers:
    default: ['drupal.dblog', 'drupal.raven']
    custom1: ['rotating_file_custom1']
    custom2: ['rotating_file_custom2']
    custom3: ['rotating_file_custom3']
services:
  monolog.handler.rotating_file_custom1:
    class: Monolog\Handler\RotatingFileHandler
    arguments: ['file://../logs/custom1.log', 25, 'monolog.level.debug']
  monolog.handler.rotating_file_custom2:
    class: Monolog\Handler\RotatingFileHandler
    arguments: ['file://../logs/custom2.log', 25, 'monolog.level.debug']
  monolog.handler.rotating_file_custom3:
    class: Monolog\Handler\RotatingFileHandler
    arguments: ['file://../logs/custom3.log', 25, 'monolog.level.debug' ]

我尝试使用 DrupalHandler 为 drupal.dblog 添加一个新的服务处理程序,但我无法弄清楚要使用哪些参数(需要参数并且它期望 LoggerInterface 实现作为第一个参数)。

我已经通读了模块文档,但它几乎只专注于文件/外部日志记录。

有什么建议吗?

TIA

1 个答案:

答案 0 :(得分:0)

我也试图实现这一点,但我也不清楚。解决方案是添加带有“@”符号作为第一个参数的核心 dblog 服务。还应该提到的是,日志级别被记录为“monolog.level.debug”,但应该在没有前缀“monolog.level”的情况下实现。因为 monolog 参数没有正确加载。这是一个工作示例:

grep -o '[[:alpha:]]*[^[:alpha:]]*'
相关问题