@@ -323,6 +323,49 @@ specific channel (``app`` by default), use the ``monolog.logger`` tag with the
323
323
``channel `` property as explained in the
324
324
:ref: `Dependency Injection reference <dic_tags-monolog >`.
325
325
326
+ How to Disable Microseconds Precision (for a Performance Boost)
327
+ ---------------------------------------------------------------
328
+
329
+ Setting the parameter ``use_microseconds `` to ``false `` forces the logger to reduce
330
+ the precision in the ``datetime `` field of the log messages from microsecond to second,
331
+ avoiding a call to the ``microtime(true) `` function and the subsequent parsing.
332
+ Disabling the use of microseconds can provide a small performance gain speeding up the
333
+ log generation. This is recommended for systems that generate a large number of log events.
334
+
335
+ .. configuration-block ::
336
+
337
+ .. code-block :: yaml
338
+
339
+ # config/packages/monolog.yaml
340
+ monolog :
341
+ use_microseconds : false
342
+ # ...
343
+
344
+ .. code-block :: xml
345
+
346
+ <!-- config/packages/monolog.xml -->
347
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
348
+ <container xmlns =" http://symfony.com/schema/dic/services"
349
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
350
+ xmlns : monolog =" http://symfony.com/schema/dic/monolog"
351
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
352
+ http://symfony.com/schema/dic/services/services-1.0.xsd
353
+ http://symfony.com/schema/dic/monolog
354
+ http://symfony.com/schema/dic/monolog/monolog-1.0.xsd" >
355
+
356
+ <monolog : config use-microseconds =" false" >
357
+ <!-- ... -->
358
+ </monolog : config >
359
+ </container >
360
+
361
+ .. code-block :: php
362
+
363
+ // config/packages/monolog.php
364
+ $container->loadFromExtension('monolog', array(
365
+ 'use_microseconds' => false,
366
+ // ...
367
+ ));
368
+
326
369
Adding extra Data to each Log (e.g. a unique request token)
327
370
-----------------------------------------------------------
328
371
@@ -343,7 +386,6 @@ Learn more
343
386
logging/processors
344
387
logging/monolog_regex_based_excludes
345
388
logging/monolog_console
346
- logging/disable_microsecond_precision
347
389
348
390
.. _Monolog : https://github.com/Seldaek/monolog
349
391
.. _LoggerInterface : https://github.com/php-fig/log/blob/master/Psr/Log/LoggerInterface.php
0 commit comments