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:
Maybe i have missed something in configuration?
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.
Monolog is a logging library for PHP 5.3 used by Symfony. It is inspired by the Python LogBook library.
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.
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.
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 .
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With