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:   ['email1@gmail.com', 'email2@gmail.com']
            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?

kRicha
  • 797
  • 9
  • 27

1 Answers1

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.

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110