Skip to content

Added a note about the rotating_file monolog handler #5137

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 3 commits into from
May 25, 2015
Merged
Changes from 2 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
46 changes: 46 additions & 0 deletions cookbook/logging/monolog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,52 @@ only for a specific handler.
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
Copy link
Member

Choose a reason for hiding this comment

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

@javiereguiluz Thanks for adding this :). I think we should move this to a whole new section - with a header like How to Rotate your Log Files so it can be easily found. OR, make a new, very-short cookbook entry (to be even easier to find).

Thanks!

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
Copy link
Member

Choose a reason for hiding this comment

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

I think we should show max_files - maybe commented out, with a comment above/on the line that says it defaults to zero (infinite)


.. code-block:: xml

<!-- app/config/config_dev.xml -->
<?xml version="1.0" charset="UTF-8" ?>
<container xmlns=''http://symfony.com/schema/dic/services"
xmlns:monolog="http://symfony.com/schema/dic/monolog">

<monolog:config>
<monolog:handler name="main"
type="rotating_file"
path="%kernel.logs_dir%/%kernel.environment%.log"
level="debug"
/>
</monolog:config>
</container>

.. 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',
),
),
));

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 <dic_tags-monolog-processor>`.
Expand Down