@@ -81,12 +81,62 @@ Creating your own Channel
81
81
-------------------------
82
82
83
83
You can change the channel monolog logs to one service at a time. This is done
84
- by tagging your service with ``monolog.logger `` and specifying which channel
85
- the service should log to. By doing this, the logger that is injected into
86
- that service is preconfigured to use the channel you've specified.
84
+ either via the :ref: `configuration <cookbook-monolog-channels-config >` below
85
+ or by tagging your service with :ref: `monolog.logger<dic_tags-monolog> ` and
86
+ specifying which channel the service should log to. With the tag, the logger
87
+ that is injected into that service is preconfigured to use the channel you've
88
+ specified.
87
89
88
- For more information - including a full example - read ":ref: `dic_tags-monolog `"
89
- in the Dependency Injection Tags reference section.
90
+ .. _cookbook-monolog-channels-config :
91
+
92
+ Configure Additional Channels without Tagged Services
93
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
+
95
+ .. versionadded :: 2.3
96
+ This feature was introduced to the MonologBundle in version 2.4. This
97
+ version is compatible with Symfony 2.3, but only MonologBundle 2.3 is
98
+ installed by default. To use this feature, upgrade your bundle manually.
99
+
100
+ With MonologBundle 2.4 you can configure additional channels without the
101
+ need to tag your services:
102
+
103
+ .. configuration-block ::
104
+
105
+ .. code-block :: yaml
106
+
107
+ # app/config/config.yml
108
+ monolog :
109
+ channels : ["foo", "bar"]
110
+
111
+ .. code-block :: xml
112
+
113
+ <!-- app/config/config.xml -->
114
+ <container xmlns =" http://symfony.com/schema/dic/services"
115
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
116
+ xmlns : monolog =" http://symfony.com/schema/dic/monolog"
117
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
118
+ http://symfony.com/schema/dic/services/services-1.0.xsd
119
+ http://symfony.com/schema/dic/monolog
120
+ http://symfony.com/schema/dic/monolog/monolog-1.0.xsd"
121
+ >
122
+ <monolog : config >
123
+ <monolog : channel >foo</monolog : channel >
124
+ <monolog : channel >bar</monolog : channel >
125
+ </monolog : config >
126
+ </container >
127
+
128
+ .. code-block :: php
129
+
130
+ // app/config/config.php
131
+ $container->loadFromExtension('monolog', array(
132
+ 'channels' => array(
133
+ 'foo',
134
+ 'bar',
135
+ ),
136
+ ));
137
+
138
+ With this, you can now send log messages to the ``foo `` channel by using
139
+ the automatically registered logger service ``monolog.logger.foo ``.
90
140
91
141
Learn more from the Cookbook
92
142
----------------------------
0 commit comments