Skip to content

fix the XML config and add the corresponding PHP config #3206

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
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
66 changes: 44 additions & 22 deletions cookbook/logging/channels_handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,65 @@ To do so, just create a new handler and configure it like this:

.. code-block:: yaml

# app/config/config.yml
monolog:
handlers:
main:
type: stream
path: /var/log/symfony.log
channels: !doctrine
type: stream
path: /var/log/symfony.log
channels: [!doctrine]
doctrine:
type: stream
path: /var/log/doctrine.log
channels: doctrine
type: stream
path: /var/log/doctrine.log
channels: [doctrine]

.. code-block:: xml

<monolog:config>
<monolog:handlers>
<!-- 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:handler name="main" type="stream" path="/var/log/symfony.log">
<monolog:channels>
<type>exclusive</type>
<channel>doctrine</channel>
<monolog:channel>!doctrine</monolog:channel>
</monolog:channels>
</monolog:handler>

<monolog:handler name="doctrine" type="stream" path="/var/log/doctrine.log" />
<monolog:handler name="doctrine" type="stream" path="/var/log/doctrine.log">
<monolog:channels>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be monolog:channel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried the XML, seems to work ok for me :)

<type>inclusive</type>
<channel>doctrine</channel>
<monolog:channel>doctrine</monolog:channel>
</monolog:channels>
</monolog:handler>
</monolog:handlers>
</monolog:config>
</monolog:config>
</container>

.. code-block:: php

// app/config/config.php
$container->loadFromExtension('monolog', array(
'handlers' => array(
'main' => array(
'type' => 'stream',
'path' => '/var/log/symfony.log',
'channels' => array(
'!doctrine',
),
),
'doctrine' => array(
'type' => 'stream',
'path' => '/var/log/doctrine.log',
'channels' => array(
'doctrine',
),
),
),
));

YAML specification
------------------
Expand All @@ -74,13 +103,6 @@ You can specify the configuration by many forms:
channels: [foo, bar] # Include only channels "foo" and "bar"
channels: [!foo, !bar] # Include all channels, except "foo" and "bar"

channels:
type: inclusive # Include only those listed below
elements: [ foo, bar ]
channels:
type: exclusive # Include all, except those listed below
elements: [ foo, bar ]

Creating your own Channel
-------------------------

Expand Down