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

My configuration is (config_prod.yml):

            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  error
            type:         fingers_crossed
            # 500 errors are logged at the critical level
            action_level: critical
             handler:      deduplicated
            type:    deduplication
            handler: swift
            type:       swift_mailer
            from_email: 'email@myserv.myserv'
            to_email:   'mymorningemail@myserv.myserv'
            subject:    'You have to work ! An Error Occurred! %%message%%'
            level:      debug
            formatter:  monolog.formatter.html
            content_type: text/html



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.