8000 add documentation for configuring additional monolog channels by xabbuh · Pull Request #3205 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

add documentation for configuring additional monolog channels #3205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions cookbook/logging/channels_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!-- app/config/config.xml -->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:monolog="http://symfony.com/schema/dic/monolog"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/monolog
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"
>
<monolog:config>
<monolog:channel>foo</monolog:channel>
<monolog:channel>bar</monolog:channel>
</monolog:config>
</container>

.. 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
----------------------------

Expand Down
6 changes: 6 additions & 0 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0