@@ -79,6 +79,7 @@ allows you to log the messages in several ways easily.
7979 ..code-block ::xml
8080
8181<!-- app/config/config.xml-->
82+ <?xml version =" 1.0" encoding =" UTF-8" ?>
8283 <container xmlns =" http://symfony.com/schema/dic/services"
8384xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
8485xmlns : monolog =" http://symfony.com/schema/dic/monolog"
@@ -179,6 +180,7 @@ easily. Your formatter must implement
179180 ..code-block ::xml
180181
181182<!-- app/config/config.xml-->
183+ <?xml version =" 1.0" encoding =" UTF-8" ?>
182184 <container xmlns =" http://symfony.com/schema/dic/services"
183185xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
184186xmlns : monolog =" http://symfony.com/schema/dic/monolog"
@@ -293,6 +295,8 @@ using a processor.
293295
294296 ..code-block ::xml
295297
298+ <!-- app/config/config.xml-->
299+ <?xml version =" 1.0" encoding =" UTF-8" ?>
296300 <container xmlns =" http://symfony.com/schema/dic/services"
297301xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
298302xmlns : monolog =" http://symfony.com/schema/dic/monolog"
@@ -346,8 +350,101 @@ using a processor.
346350
347351 ..note ::
348352
349- If you use several handlers, you can also register the processor at the
350- handler level instead of globally.
353+ If you use several handlers, you can also register a processor at the
354+ handler level or at the channel level instead of registering it globally
355+ (see the following sections).
356+
357+ Registering Processors per Handler
358+ ----------------------------------
359+
360+ You can register a processor per handler using the ``handler `` option of
361+ the ``monolog.processor `` tag:
362+
363+ ..configuration-block ::
364+
365+ ..code-block ::yaml
366+
367+ # app/config/config.yml
368+ services :
369+ monolog.processor.session_request :
370+ class :Acme\MyBundle\SessionRequestProcessor
371+ arguments :["@session"]
372+ tags :
373+ -{ name: monolog.processor, method: processRecord, handler: main }
374+
375+ ..code-block ::xml
376+
377+ <!-- app/config/config.xml-->
378+ <?xml version =" 1.0" encoding =" UTF-8" ?>
379+ <container xmlns =" http://symfony.com/schema/dic/services"
380+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
381+ xmlns : monolog =" http://symfony.com/schema/dic/monolog"
382+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
383+ http://symfony.com/schema/dic/services/services-1.0.xsd
384+ http://symfony.com/schema/dic/monolog
385+ http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"
386+ >
387+ <services >
388+ <service id =" monolog.processor.session_request" class =" Acme\MyBundle\SessionRequestProcessor" >
389+ <argument type =" service" id =" session" />
390+ <tag name =" monolog.processor" method =" processRecord" handler =" main" />
391+ </service >
392+ </services >
393+ </container >
394+
395+ ..code-block ::php
396+
397+ // app/config/config.php
398+ $container
399+ ->register('monolog.processor.session_request', 'Acme\MyBundle\SessionRequestProcessor')
400+ ->addArgument(new Reference('session'))
401+ ->addTag('monolog.processor', array('method' => 'processRecord', 'handler' => 'main'));
402+
403+ Registering Processors per Channel
404+ ----------------------------------
405+
406+ You can register a processor per channel using the ``channel `` option of
407+ the ``monolog.processor `` tag:
408+
409+ ..configuration-block ::
410+
411+ ..code-block ::yaml
412+
413+ # app/config/config.yml
414+ services :
415+ monolog.processor.session_request :
416+ class :Acme\MyBundle\SessionRequestProcessor
417+ arguments :["@session"]
418+ tags :
419+ -{ name: monolog.processor, method: processRecord, channel: main }
420+
421+ ..code-block ::xml
422+
423+ <!-- app/config/config.xml-->
424+ <?xml version =" 1.0" encoding =" UTF-8" ?>
425+ <container xmlns =" http://symfony.com/schema/dic/services"
426+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
427+ xmlns : monolog =" http://symfony.com/schema/dic/monolog"
428+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
429+ http://symfony.com/schema/dic/services/services-1.0.xsd
430+ http://symfony.com/schema/dic/monolog
431+ http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"
432+ >
433+ <services >
434+ <service id =" monolog.processor.session_request" class =" Acme\MyBundle\SessionRequestProcessor" >
435+ <argument type =" service" id =" session" />
436+ <tag name =" monolog.processor" method =" processRecord" channel =" main" />
437+ </service >
438+ </services >
439+ </container >
440+
441+ ..code-block ::php
442+
443+ // app/config/config.php
444+ $container
445+ ->register('monolog.processor.session_request', 'Acme\MyBundle\SessionRequestProcessor')
446+ ->addArgument(new Reference('session'))
447+ ->addTag('monolog.processor', array('method' => 'processRecord', 'channel' => 'main'));
351448
352449 .. _Monolog :https://github.com/Seldaek/monolog
353450.. _LoggerInterface :https://github.com/php-fig/log/blob/master/Psr/Log/LoggerInterface.php