Milliseconds in \ Monolog \ Formatter \ LineFormatter (PHP)

I am using Cascade 'ed Monolog and configure the loggers using YAML. This is part of my configuration:

formatters: dashed: class: Monolog\Formatter\LineFormatter format: "%datetime%-%channel%.%level_name% - %message%\n" 

This is a formatted log line:

 2016-12-13 17:49:16-app.INFO - <message> 

What is the format value for \Monolog\Formatter\LineFormatter to get a timestamp with milliseconds?

+5
source share
1 answer

In my Symfony 2.6 project, I have my own log handler, so I implemented the log as a service, if it can help here, this is part of the service.yml declaration code; if you look at logger_formatter, the second argument to the contructor class is the date format:

 mybundle.logger: class: Symfony\Bridge\Monolog\Logger arguments: [mybundle] # channel calls: - [pushHandler, [@mybundle.logger_handler]] - [pushProcessor, [@mybundle.logger_processor]] mybundle.logger_processor: class: myBundle\Logging\LogProcessor arguments: ["@session"] mybundle.logger_handler: class: myBundle\Logging\myBundleRotatingFileHandler #Monolog\Handler\RotatingFileHandler arguments: ["@session", %kernel.logs_dir%/LOGGER_SID/%kernel.environment%.mybundle.log, 0, 400] #DEBUG = 100; INFO = 200; NOTICE = 250; WARNING = 300; ERROR = 400; CRITICAL = 500; ALERT = 550; EMERGENCY = 600; calls: - [setFormatter, [@mybundle.logger_formatter]] - [setFilenameFormat, ['{filename}','Ym-d']] mybundle.logger_formatter: class: Monolog\Formatter\LineFormatter arguments: - "[%%datetime%%]\t%%extra.remote_addr%%\t%%level_name%%\t%%message%%\t%%extra.request_uri%%\n" - "Ymd H:i:su" 
0
source

Source: https://habr.com/ru/post/1261213/


All Articles