문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top