Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Configure Guzzle Logger Middleware to log into a different Monolog channel #244

Open
florianpreusner opened this issue Nov 24, 2018 · 0 comments

Comments

@florianpreusner
Copy link
Member

Created monolog.yml under /config (SF 4.1):

    use_microseconds: false

    channels:
        - eight_points_guzzle

    handlers:
        eight_points_guzzle:
            channels: [eight_points_guzzle]
            type: stream
            path: "%kernel.logs_dir%/eight_points_guzzle.log"
            level: info

---- created from comment by renatogcarvalho (Symfony Dev Slack, #8p-guzzlebundle, 18/11/24, 9:49 AM) ----

Hello @channel!

First of all, thank you for this amazing bundle. It was great to find a tool to accomplish exactly what I was already working on. Much appreciated.
I got a question though. Is there a way to configure the Guzzle Logger Middleware to log into a different Monolog channel?
Usually I like to organize my application logs into different channels sometimes specific to some services just so I can tail logs for that service alone without doing any grep, etc.
Also, for some reason it looks like the formatter override is not working for me. Maybe I'm doing something wrong?

    eight_points_guzzle.symfony_log_formatter.pattern: '[{datetime}] guzzle.{log_level}: HTTP/{code} {method} {uri} {res_body}'

output:

It seems that is appending instead of replacing.
Oh I see, it looks like you only allow to override the message itself, not the whole line.

renatogcarvalho [9:49 AM]
Ok, regarding the issue related with the Monolog channel I figured out how to configure it to log into a different file. Just for future reference for anybody that might be interested in accomplish this as well.

Created monolog.yml under /config (SF 4.1):

    use_microseconds: false

    channels:
        - eight_points_guzzle

    handlers:
        eight_points_guzzle:
            channels: [eight_points_guzzle]
            type: stream
            path: "%kernel.logs_dir%/eight_points_guzzle.log"
            level: info

You guys might be interested in documenting this. Have a good one everybody.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant