Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

monolog sending old logs

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?

like image 519
kRicha Avatar asked Sep 06 '18 09:09

kRicha


People also ask

What is monolog logger?

Monolog is the existing standard logging library for PHP. It is most popular in PHP frameworks such as Laravel and Symfony, where it implements a common interface for logging libraries.

What is Monolog Symfony?

Monolog is a logging library for PHP 5.3 used by Symfony. It is inspired by the Python LogBook library.

Where are Symfony logs?

Logging in Symfony By default, Symfony logs are stored in var/log/dev. log and var/log/prod. log within the project directory, depending on the environment, but these defaults can be changed in the Monolog package configuration file found at config/packages/monolog.

Where does monolog send my logs?

This is the documentation for Monolog 3.x, if you are using older releases see the documentation for Monolog 2.x or Monolog 1.x Monolog sends your logs to files, sockets, inboxes, databases and various web services. See the complete list of handlers below. Special handlers allow you to build advanced logging strategies.

What is monolog in PHP?

Monolog is a popular PHP logging library. It allows to send logs to files, sockets, inboxes, databases and various web services. It implements the PSR-3 interface. We install Monolog with composer. A Monolog logger instance has a channel (name) and a stack of handlers .

What is the Monolog library?

Monolog is an open-source PHP library that aims to make logging easier and more efficient. To see the library source code, visit Monolog on GitHub. Finding bugs in the code may be very frustrating and time-consuming, especially, when the application grows in scale.

How do I format a monolog log message to JSON?

Monolog has multiple built-in formatters that are used to transform your log message to the desired format. A full list of the built-in formatters can be found on the official GitHub documentation. In this example, we will use a JSON formatter that will transform the message to the JSON format.


1 Answers

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.

like image 131
Alister Bulman Avatar answered Nov 15 '22 10:11

Alister Bulman