Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python logging time since start of program

Tags:

python

logging

I'm using the logging module to create loggers and output data. Instead of using $(asctime)s in logging.Formatter, is there a good way to log the timestamp relative to the creation of the logger?

like image 862
dpington Avatar asked Aug 08 '14 01:08

dpington


Video Answer


1 Answers

Using %(relativeCreated)d field in a conventional Formatter format string will display the milliseconds elapsed since the logging module was loaded. While milliseconds might not be what you want, there's no additional coding required.

like image 150
Vinay Sajip Avatar answered Sep 20 '22 08:09

Vinay Sajip