MonologBundle records everything using the same handlers for the entire structure. This means that if one of your services needs to connect to various handlers, you must create your own Logger / Handler and enter it into your service.
This could be a config example (in yaml):
services: my_logger: class: Symfony\Bridge\Monolog\Logger arguments: [soap] calls: - [pushHandler, [@my_handler]] my_handler: class: Monolog\Handler\StreamHandler # 200 = INFO, see Monolog::Logger for the values of log levels arguments: [%kernel.root_dir%/%kernel.environment%.soap.log, 200] soap_service: class: Your\Soap\Client arguments: [@my_logger]
Hope this clarifies this.
Update: as in Symfony 2.1, you can also configure which channels these handlers will receive so you can do something like this:
services: soap_service: class: Your\Soap\Client arguments: [@logger] tags: - { name: monolog.logger, channel: soap }
What creates a new soap channel (i.e., a registrar instance that receives all the handlers), and then configure different handlers for this channel:
monolog: handlers: main: type: stream path: %kernel.root_dir%/%kernel.environment%.log level: error channels: [!soap] soap: type: stream path: %kernel.root_dir%/%kernel.environment%.soap.log level: info channels: [soap]
This means that the main processor will receive everything except the soap channel, and the soap processor will receive only the soap channel. You can also remove the channels key on the main handler if you want your main log file to have everything, but also have a copy of only soap logs separately. This brings great flexibility, and as you can see, the channels are an array, so you can list the channels you need or use the !name blacklist notation to exclude some of them and include everything else.
Seldaek Nov 21 '11 at 11:16 2011-11-21 11:16
source share