Skip to content

Commit 7345c17

Browse files
committed
Added XML and PHP configuration samples
1 parent 31fd0db commit 7345c17

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

cookbook/logging/monolog.rst

+40-9
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,46 @@ only for a specific handler.
241241
a new log file every day and can also remove old files automatically. To use
242242
it, just set the ``type`` option of your handler to ``rotating_file``:
243243

244-
.. code-block:: yaml
245-
246-
# app/config/config_dev.yml
247-
monolog:
248-
handlers:
249-
main:
250-
type: rotating_file # <-- this value is usually 'stream'
251-
path: %kernel.logs_dir%/%kernel.environment%.log
252-
level: debug
244+
.. configuration-block::
245+
246+
.. code-block:: yaml
247+
248+
# app/config/config_dev.yml
249+
monolog:
250+
handlers:
251+
main:
252+
type: rotating_file
253+
path: %kernel.logs_dir%/%kernel.environment%.log
254+
level: debug
255+
256+
.. code-block:: xml
257+
258+
<!-- app/config/config_dev.xml -->
259+
<?xml version="1.0" charset="UTF-8" ?>
260+
<container xmlns=''http://symfony.com/schema/dic/services"
261+
xmlns:monolog="http://symfony.com/schema/dic/monolog">
262+
263+
<monolog:config>
264+
<monolog:handler name="main"
265+
type="rotating_file"
266+
path="%kernel.logs_dir%/%kernel.environment%.log"
267+
level="debug"
268+
/>
269+
</monolog:config>
270+
</container>
271+
272+
.. code-block:: php
273+
274+
// app/config/config_dev.php
275+
$container->loadFromExtension('monolog', array(
276+
'handlers' => array(
277+
'main' => array(
278+
'type' => 'rotating_file',
279+
'path' => '%kernel.logs_dir%/%kernel.environment%.log',
280+
'level' => 'debug',
281+
),
282+
),
283+
));
253284
254285
A processor is simply a callable receiving the record as its first argument.
255286
Processors are configured using the ``monolog.processor`` DIC tag. See the

0 commit comments

Comments
 (0)