468,294 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,294 developers. It's quick & easy.

logging module: log file with datetime

Hi

I have this logging config file;

================================================== ==================

[loggers]
keys=cdmto

[handlers]
keys=cdmtoHandler

[formatters]
keys=mtoFormatter

[logger_cdmto]
level=DEBUG
handlers=cdmtoHandler
qualname=cdmto
propagate=0

[handler_cdmtoHandler]
class=handlers.TimedRotatingFileHandler
level=DEBUG
formatter=mtoFormatter
args=('./Logs/cdmto.log',)

[formatter_mtoFormatter]
format=%(asctime)s %(levelname)-8s %(filename)s[%(lineno)d]: %
(message)s
datefmt=

================================================== ==================

How could I define a log file with datetime in his name?. Now the
name
for log file is './Logs/cdmto.log' and I'd like it would be './
Logs/cdmto_20070601.log',
for example.

Thanks.

Jun 1 '07 #1
1 1780
On 1 Jun, 13:00, Álvaro Nieto <alvaro.ni...@gmail.comwrote:
How could I define a log file with datetime in his name?. Now the
name
for log file is './Logs/cdmto.log' and I'd like it would be './
Logs/cdmto_20070601.log',
for example.
You can't do this just in the configuration - TimedRotatingFileHandler
automatically works out the filename in a predetermined manner when
doing rollover (dependent on whether it's doing rollovers daily,
hourly or whatever period). If you need more specific handling, you'll
need to write a subclass of TimedRotatingFileHandler which does what
you need.

Regards,

Vinay Sajip

Jun 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Robert.Schmitt | last post: by
8 posts views Thread by Steve Erickson | last post: by
6 posts views Thread by Ville Vainio | last post: by
7 posts views Thread by Leo Breebaart | last post: by
7 posts views Thread by flupke | last post: by
3 posts views Thread by seb | last post: by
3 posts views Thread by Lowell Alleman | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.