By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,036 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,036 IT Pros & Developers. It's quick & easy.

logging module: log file with datetime

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.