diff --git a/cookbook/logging/channels_handlers.rst b/cookbook/logging/channels_handlers.rst index 18e99350d5d..03bf3245044 100644 --- a/cookbook/logging/channels_handlers.rst +++ b/cookbook/logging/channels_handlers.rst @@ -88,6 +88,57 @@ that service is preconfigured to use the channel you've specified. For more information - including a full example - read ":ref:`dic_tags-monolog`" in the Dependency Injection Tags reference section. +.. _cookbook-monolog-channels-config: + +Configure Additional Channels without Tagged Services +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 2.3 + Since Symfony 2.3 you can install MonologBundle 2.4 to be able to configure + additional channels in the configuration. + +With MonologBundle 2.4 you can configure additional channels without the +need to tag your services: + +.. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + monolog: + channels: ["foo", "bar"] + + .. code-block:: xml + + + + + foo + bar + + + + .. code-block:: php + + // app/config/config.php + $container->loadFromExtension('monolog', array( + 'channels' => array( + 'foo', + 'bar', + ), + )); + +With this, you can now send log messages to the ``foo`` channel by using +the automically registered logger service ``monolog.logger.foo``. + + Learn more from the Cookbook ---------------------------- diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 06674bbb953..92e1fbcede3 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -649,6 +649,12 @@ channel when injecting the logger in a service. $definition->addTag('monolog.logger', array('channel' => 'acme')); $container->register('my_service', $definition); +.. tip:: + If you use MonologBundle in version 2.4 or above, you are able to configure + your custom channels in the application configuration and retrieve the + corresponding logger service from the service container directly (see + :ref:`cookbook-monolog-channels-config`). + .. _dic_tags-monolog-processor: monolog.processor