Artisan DĂ©veloppeur

Qualité, amélioration continue, agilité.

Don’t miss 500 internal error anymore with symfony and monolog

Sometimes I read my server logs … Like some people read the newspaper, in fact server logs are like the app newspaper 🙂

Every morning I am reading my logwatch email.

But I can miss errors, and even if I see them, it is the next day in my logs email, and it is really BAD

The solution is simple, use monolog to send you errors directly

https://symfony.com/doc/current/logging/monolog_email.html

My configuration is (config_prod.yml):

[pastacode lang= »markup » manual= »monolog%3A%0A%20%20%20%20handlers%3A%0A%20%20%20%20%20%20%20%20main%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20%20%20stream%0A%20%20%20%20%20%20%20%20%20%20%20%20path%3A%20%20%20%22%25kernel.logs_dir%25%2F%25kernel.environment%25.log%22%0A%20%20%20%20%20%20%20%20%20%20%20%20level%3A%20%20error%0A%20%20%20%20%20%20%20%20mail%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20%20%20%20%20%20%20%20%20fingers_crossed%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20500%20errors%20are%20logged%20at%20the%20critical%20level%0A%20%20%20%20%20%20%20%20%20%20%20%20action_level%3A%20critical%0A%20%20%20%20%20%20%20%20%20%20%20%20%20handler%3A%20%20%20%20%20%20deduplicated%0A%20%20%20%20%20%20%20%20deduplicated%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20%20%20%20deduplication%0A%20%20%20%20%20%20%20%20%20%20%20%20handler%3A%20swift%0A%20%20%20%20%20%20%20%20swift%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20%20%20%20%20%20%20swift_mailer%0A%20%20%20%20%20%20%20%20%20%20%20%20from_email%3A%20’email%40myserv.myserv’%0A%20%20%20%20%20%20%20%20%20%20%20%20to_email%3A%20%20%20’mymorningemail%40myserv.myserv’%0A%20%20%20%20%20%20%20%20%20%20%20%20subject%3A%20%20%20%20’You%20have%20to%20work%20!%20An%20Error%20Occurred!%20%25%25message%25%25’%0A%20%20%20%20%20%20%20%20%20%20%20%20level%3A%20%20%20%20%20%20debug%0A%20%20%20%20%20%20%20%20%20%20%20%20formatter%3A%20%20monolog.formatter.html%0A%20%20%20%20%20%20%20%20%20%20%20%20content_type%3A%20text%2Fhtml » message= » » highlight= » » provider= »manual »/]

 

 

Leave a reply

Your email address will not be published.

Ce site utilise Akismet pour réduire les indésirables. En savoir plus sur comment les données de vos commentaires sont utilisées.