How to Disable Microseconds Precision (for a Performance Boost)

Version: 3.0
Edit this page

Warning: You are browsing the documentation for Symfony 3.0, which is no longer maintained.

Read the updated version of this page for Symfony 5.3 (the current stable version).

How to Disable Microseconds Precision (for a Performance Boost)

New in version 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.

  • YAML
  • XML
  • PHP
1
2
3
4
5
6
7
8
# app/config/config.yml
monolog:
    use_microseconds: false
    handlers:
        applog:
            type: stream
            path: /var/log/symfony.log
            level: error
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.