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

Error Outputting Logs from Guzzle Channel #35

Open
rsahlstrom opened this issue Sep 13, 2013 · 2 comments
Open

Error Outputting Logs from Guzzle Channel #35

rsahlstrom opened this issue Sep 13, 2013 · 2 comments

Comments

@rsahlstrom
Copy link
Contributor

I attempted to setup guzzle log messages to go to another file by adding the following to my monolog config.

monolog:
    handlers:
        guzzle:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.guzzle.log"
            level: debug
            channels: guzzle

This appears like it should work and that this bundle should create the channel as seen in the bundle's monolog.xml file.

        <service id="misd_guzzle.log.adapter.monolog" class="%guzzle.log.adapter.monolog.class%" public="false">
            <tag name="monolog.logger" channel="guzzle"/>
            <argument type="service" id="monolog.logger" on-invalid="ignore"/>
        </service>

However, I was getting errors stating the following when running symfony:

[InvalidArgumentException]                                                                                  
Monolog configuration error: The logging channel "guzzle" assigned to the "guzzle" handler does not exist.

Researching this, I found that monolog.xml with the channel setup was being added via a CompilerPass. The monolog bundle also uses a compilerPass to find all services tagged with monolog.logger to create the necessary channels.

The problem I was having was the Monolog bundle's compiler pass was running first and thus the service misd_guzzle.log.adapter.monolog service hadn't been added to the container yet and was thus not fund and the guzzle channel not created.

To fix this issue, I've updated my AppKernel from:

$bundles = array(
      new Symfony\Bundle\MonologBundle\MonologBundle(),
      new Misd\GuzzleBundle\MisdGuzzleBundle(),
);

to:

$bundles = array(
      new Misd\GuzzleBundle\MisdGuzzleBundle(),
      new Symfony\Bundle\MonologBundle\MonologBundle(),
);

This results in the guzzle bundle's compiler pass running first and injecting misd_guzzle.log.adapter.monolog into the container. The monolog bundle's compiler pass then correctly finds it and creates the guzzle channel.

Is there a better way to fix this? If not, should a note be added in the setup process mentioning the issue and solution?

Thanks for the hard work on this bundle!

@thewilkybarkid
Copy link
Contributor

Sorry for not looking at this sooner. If you're still seeing this does moving the misd_guzzle.log.adapter.monolog service to the services.xml file resolve it? If it does, we could change the MonologCompilerPass so that it just adds the misd_guzzle.plugin tag to the misd_guzzle.log.monolog service (as opposed to loading a new configuration file). If Monolog isn't enabled then the services won't be created (I'm assuming there wouldn't be a problem, clearly needs checking!).

@evgeny-s
Copy link

Hello.
Looks like logs from guzzle putting to app.DEBUG channel. Could you please tell the way to put guzzle logs to guzzle.DEBUG channel and put logs to separate log file. I did all above steps, but no new file was created and logs still in app.DEBUG section.

Thank you.

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

No branches or pull requests

3 participants