monolog sending old logs
Asked Answered
C

1

7

W have web-app, built with symfony-flex. For deployment, I am using capistrano. For logging critical logs, I have configured monolog in this way:

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:   ['[email protected]', '[email protected]']
            subject:    "πŸ“žπŸš¨ %%level_name%% %%level%%"
            level:      info
            formatter:  monolog.formatter.html
            content_type: text/html

SwiftMailer configuration:

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

And all works fine except logs after each release. I'm getting old logs which were sent before. Example:

screenshot

Maybe i have missed something in configuration?

Course answered 6/9, 2018 at 9:23 Comment(6)
This might have something to do with swiftmailer's spooler. Can you show us the Swiftmailer config? – Whitish
@EmanuelOster i use default one, added to question. – Course
Did you solve your problem, yet? – Tarry
Did you check this is not a mail server issue with both sides of outgoing and incoming servers? Mail servers can queue mails when there is a lot request and this might be both end of mail transaction. Maybe you can test this with simple local smtp server like MailDev github.com/djfarrelly/MailDev – Lines
what i always do is removing this line. spool: { type: 'memory' } – Supertonic
@PuyaSarmidani thanks, I'll try – Course
C
1

The MonologBundle configuration for the deduplication handler type has additional potential parameters - including

store: The file/path where the deduplication log should be kept, defaults to %kernel.cache_dir%/monolog_dedup_*

It is re-reading the file that is in the cache directory from before you deployed.

I also deploy my site(s) with Capistrano - but I do not share the cache directory between different deploys of my site. My config for shared files is set :linked_dirs, [fetch(:log_path)] - only shares the logs to keep updating them in the long term. The cache directory is still in ./var/cache, but it's freshly created on each deployment.

Chilly answered 13/9, 2019 at 23:48 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.