Question

I created channel into service container tags in services.yml

 parameters:
     restApiClass: "Telnet\ApiBundle\Services\RestApi"

 services:

     restApi: 
         class:      "%restApiClass%" 
         arguments: [@logger]
         tags:                                                                                                                                                                                 
             - { name: monolog.logger, channel: rest_api } 

then configured monolog's handlers to write this channel to different file

monolog:
    handlers:
        main:
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            channels: [!rest_api]
        rest_api:
            type: stream
            path: "%kernel.logs_dir%/api.%kernel.environment%.error.log"
            level: error
            channels: [rest_api]
        firephp:
            type:  firephp
            level: info
        chromephp:
            type:  chromephp
            level: info

But I got an error:

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

What i need to do to make it works in the way that i want? BTW I'm using Symfony 2.3 version with LTS

Was it helpful?

Solution

Hmm, silly me. I created bundle by hand, but forgot load it in AppKernel. Sorry =)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top