Borja Pombo
Borja Pombo

Reputation: 535

Configuring monolog in Symfony2

I'm trying to optimize my project logs (Because my log got 3Gb at now) so that when something goes wrong the server send me an email with the details of the error.

I would like to appear in the log only major errors, such as 500 errors, errors that affect the proper functioning of the project.

I have looked at the documentation of the bundle of monolog on the official Symfony2 but I have not been at all clear.

(http://symfony.com/doc/current/reference/configuration/monolog.html)

Could someone tell me how to get this?

Upvotes: 0

Views: 261

Answers (2)

LBA
LBA

Reputation: 4089

We defined

monolog:
    handlers:
        main:
            action_level: error

in our production environment. Of course you have to check which handler (in our case: 'main') you need to adapt but by changing the action_level to 'error' you get rid of all the debug/info statements in your log and only level 'error' is shown.

Please check your Swift part: You have level: 'debug' which is obviously not corresponding with your requirement. You should use 'error' or 'critical' instead. See http://symfony.com/doc/current/cookbook/logging/monolog_email.html as well.

Generally it would be helpful to know what kind of log is producing too much and what kind of information? (e.g. we put Doctrine to a different monolog channel to get rid of it in our main log).

Upvotes: 1

Borja Pombo
Borja Pombo

Reputation: 535

Here is my config for monolog.

monolog:
    handlers:
        main:
            action_level: error
        console:
            type:   console
            bubble: false
        mail:
            type: fingers_crossed
            action_level: critical
            handler: buffered
        buffered:
            type: buffer
            handler: swift
        swift:
            type: swift_mailer
            from_email: [email protected]
            to_email: [email protected]
            subject: Critical error spotted
            level: debug

Upvotes: 0

Related Questions