formatting time as milliseconds in logging module

Vinay Sajip vinay_sajip at yahoo.co.uk
Wed Oct 20 05:16:13 EDT 2004


Stefan Behnel <behnel_ml at dvs1.informatik.tu-darmstadt.de> wrote in message news:<cl2n3g$2lt$1 at lnx107.hrz.tu-darmstadt.de>...
> Hi!
> 
> The logging module nicely prepends each line with a formatted date.
> 
> However, I'm not interested in the actual date but only in the number of 
> milliseconds that passed since the start of the program. What is the best 
> way of doing that?
> 
> Thanks,
> Stefan

Use the relativeCreated attribute of the LogRecord in your message format. See

http://www.red-dove.com/logging/public/logging.Formatter-class.html

Regards,


Vinay Sajip



More information about the Python-list mailing list