Skip to content

Commit

Permalink
feature #6583 Adding a description for the use_microseconds parameter…
Browse files Browse the repository at this point in the history
… introduced in MonologBundle v2.11 (jorgelbg)

This PR was squashed before being merged into the 2.3 branch (closes #6583).

Discussion
----------

Adding a description for the use_microseconds parameter introduced in MonologBundle v2.11

This adds a small paragraph bellow the usage section with an explanation and an example block.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | >= 2.3
| Fixed tickets | #6466

Commits
-------

4c5d42f Adding a description for the use_microseconds parameter introduced in MonologBundle v2.11
  • Loading branch information
xabbuh committed May 21, 2016
2 parents 5bdb6d3 + 4c5d42f commit 3d98b28
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions cookbook/logging/monolog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,67 @@ option of your handler to ``rotating_file``:
),
));
How to Disable Microseconds Precision
-------------------------------------

.. versionadded:: 2.11
The ``use_microseconds`` option was introduced in MonologBundle 2.11.

Setting the parameter ``use_microseconds`` to ``false`` forces the logger to reduce
the precision in the ``datetime`` field of the log messages from microsecond to second,
avoiding a call to the ``microtime(true)`` function and the subsequent parsing.
Disabling the use of microseconds can provide a small performance gain speeding up the
log generation. This is recommended for systems that generate a large number of log events.

.. configuration-block::

.. code-block:: yaml
# app/config/config.yml
monolog:
use_microseconds: false
handlers:
applog:
type: stream
path: /var/log/symfony.log
level: error
.. code-block:: xml
<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<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 use_microseconds="false">
<monolog:handler
name="applog"
type="stream"
path="/var/log/symfony.log"
level="error"
/>
</monolog:config>
</container>
.. code-block:: php
// app/config/config.php
$container->loadFromExtension('monolog', array(
'use_microseconds' => false,
'handlers' => array(
'applog' => array(
'type' => 'stream',
'path' => '/var/log/symfony.log',
'level' => 'error',
),
),
));
Adding some extra Data in the Log Messages
------------------------------------------

Expand Down

0 comments on commit 3d98b28

Please sign in to comment.