7

W 有 web-app,用 symfony-flex 构建。对于部署,我使用capistrano。对于记录关键日志,我以这种方式配置了独白:

monolog:
    handlers:
        main:
            type: fingers_crossed
            action_level: error
            channels: ['!translation']
            excluded_http_codes: [{ 404: ['^/security/login'] }]
            handler: grouped
        grouped:
            type: group
            members: [deduplicated]
        deduplicated:
            type:    deduplication
            handler: swift
        swift:
            type:       swift_mailer
            from_email: '%mailer_user%'
            to_email:   ['email1@gmail.com', 'email2@gmail.com']
            subject:    " %%level_name%% %%level%%"
            level:      info
            formatter:  monolog.formatter.html
            content_type: text/html

SwiftMailer 配置:

swiftmailer:
    url: '%env(MAILER_URL)%'
    spool: { type: 'memory' }

除了每次发布后的日志外,一切正常。我收到了以前发送的旧日志。例子:

截屏

也许我错过了配置中的一些东西?

4

1 回答 1

1

处理程序类型的 MonologBu​​ndle 配置deduplication具有额外的潜在参数 - 包括

store: 应该保存去重日志的文件/路径,默认为 %kernel.cache_dir%/monolog_dedup_*

它正在重新读取部署之前缓存目录中的文件。

我还使用 Capistrano 部署我的站点 - 但我不会在我的站点的不同部署之间共享缓存目录。我对共享文件的配置是set :linked_dirs, [fetch(:log_path)]- 仅共享日志以长期更新它们。缓存目录仍在 ./var/cache 中,但它是在每次部署时新创建的。

于 2019-09-13T23:48:49.630 回答