diff --git a/cookbook/logging/monolog.rst b/cookbook/logging/monolog.rst index 376bf5affba..801776ecad8 100644 --- a/cookbook/logging/monolog.rst +++ b/cookbook/logging/monolog.rst @@ -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 + + + + + + + + + + + .. 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 ------------------------------------------