tracking/ordering log files

N

nik

Hi,

I heard that there was a utility for keeping files and specifically
log files organized, but haven't been able to find anything but the
logging class. The logging class seems to help create the content of a
log file, but unless I am missing something, it doesn't keep track of
multiple log files.

What I am looking for is some utility that allows me to create a log
file, say test.log, when the program runs. Then the next time it runs
it will see that test.log already exists and will create test.log.1 or
something similiar. Ideally it would also be able to throw out log
files that are older than a certain date or sequence, so if we got to
creating the 10th file it would delete the first one and so on.

I am sorry for the ambiguois question, but I was told this existed,
can't find it and would like to know if I'm on a wild goose chase and
should just put something together myself.

Thank you,
Nik
 
N

nik

Hi,

I heard that there was a utility for keeping files and specifically
log files organized, but haven't been able to find anything but the
logging class. The logging class seems to help create the content of a
log file, but unless I am missing something, it doesn't keep track of
multiple log files.

What I am looking for is some utility that allows me to create a log
file, say test.log, when the program runs. Then the next time it runs
it will see that test.log already exists and will create test.log.1 or
something similiar. Ideally it would also be able to throw out log
files that are older than a certain date or sequence, so if we got to
creating the 10th file it would delete the first one and so on.

I am sorry for the ambiguois question, but I was told this existed,
can't find it and would like to know if I'm on a wild goose chase and
should just put something together myself.

Thank you,
Nik


I think it is called "logfile rotation" and see some links about
log4py, but no description of what that is.
thanks
 
N

nik

OK, that's it,
so to do what I want I am using:
self.logger = logging.getLogger('debuglog')
hdlr = logging.handlers.RotatingFileHandler(debugfilename,
'a', 0, 5)
hdlr.doRollover()
formatter = logging.Formatter('%(asctime)s %
(levelname)s: %(message)s')
hdlr.setFormatter(formatter)
self.logger.addHandler(hdlr)


Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top