diff --git a/cookbook/logging/monolog.rst b/cookbook/logging/monolog.rst
index 6093fa85589..7b05f9f9e79 100644
--- a/cookbook/logging/monolog.rst
+++ b/cookbook/logging/monolog.rst
@@ -222,6 +222,69 @@ easily. Your formatter must implement
),
));
+How to Rotate your Log Files
+----------------------------
+
+Beware that log file sizes can grow very rapidly, leading to disk space exhaustion.
+This is specially true in the ``dev`` environment, where a simple request can
+generate hundreds of log lines. Consider using tools like the `logrotate`_
+Linux command to rotate log files before they become a problem.
+
+In case you cannot use a dedicated tool for rotating log files, consider using
+the special ``rotating_file`` handler defined by Monolog. This handler creates
+a new log file every day and can also remove old files automatically. To use
+it, just set the ``type`` option of your handler to ``rotating_file``:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ # app/config/config_dev.yml
+ monolog:
+ handlers:
+ main:
+ type: rotating_file
+ path: %kernel.logs_dir%/%kernel.environment%.log
+ level: debug
+ # max number of log files to keep
+ # defaults to zero, which means infinite files
+ max_files: 10
+
+ .. code-block:: xml
+
+
+
+
+
+
+
+ max_files="10"
+ />
+
+
+
+ .. code-block:: php
+
+ // app/config/config_dev.php
+ $container->loadFromExtension('monolog', array(
+ 'handlers' => array(
+ 'main' => array(
+ 'type' => 'rotating_file',
+ 'path' => '%kernel.logs_dir%/%kernel.environment%.log',
+ 'level' => 'debug',
+ // max number of log files to keep
+ // defaults to zero, which means infinite files
+ 'max_files' => 10,
+ ),
+ ),
+ ));
+
Adding some extra Data in the Log Messages
------------------------------------------
@@ -229,13 +292,6 @@ Monolog allows you to process the record before logging it to add some
extra data. A processor can be applied for the whole handler stack or
only for a specific handler.
-.. tip::
-
- Beware that log file sizes can grow very rapidly, leading to disk space exhaustion.
- This is specially true in the ``dev`` environment, where a simple request can
- generate hundreds of log lines. Consider using tools like the `logrotate`_
- Linux command to rotate log files before they become a problem.
-
A processor is simply a callable receiving the record as its first argument.
Processors are configured using the ``monolog.processor`` DIC tag. See the
:ref:`reference about it `.