473,224 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

TimedRotatingFileHandler() isn't rotating at midnight?

I set this up 3 days ago and have not seen any of the logs I've
created this way being rotated. I expected them to rotate every
midnight. I'm calling the code that uses this logger many times, each
a separate run, if that matters.

Am I doing something stupid? I can't find anything on google and don't
see anything in the code that would prevent rotating.

Thanks.

import logging, logging.handlers
logging.getLogger().setLevel(logging.DEBUG) # override default of WARNING

logfile = logging.handlers.TimedRotatingFileHandler(filename , 'midnight', 1, backupCount=14)
logfile.setLevel(logging.DEBUG)
logfile.setFormatter(logging.Formatter('%(asctime) s %(levelname)-8s %(module)s: %(message)s'))
logging.getLogger().addHandler(logfile)
Feb 1 '07 #1
4 23320
On 1 Feb, 05:32, Chris Shenton <chris-list-pyt...@shenton.orgwrote:
I set this up 3 days ago and have not seen any of the logs I've
created this way being rotated. I expected them to rotate every
midnight. I'm calling the code that uses this logger many times, each
a separate run, if that matters.
It might. I assume you have a long-running process which runs past
midnight - that's the scenario that TimedRotatingFileHandler is meant
for. Can you post a complete minimal example which shows the problem?
Am I doing something stupid? I can't find anything on google and don't
see anything in the code that would prevent rotating.
Rotating should happen when the logging process creates the handler
before midnight and makes a logging call destined for that handler
after midnight.

Regards,

Vinay Sajip

Feb 9 '07 #2
"Vinay Sajip" <vi*********@yahoo.co.ukwrites:
It might. I assume you have a long-running process which runs past
midnight - that's the scenario that TimedRotatingFileHandler is meant
for. Can you post a complete minimal example which shows the problem?
Rotating should happen when the logging process creates the handler
before midnight and makes a logging call destined for that handler
after midnight.
Ah, then maybe I'm expecting the wrong thing. The python code is
invoked from cron every 10 minutes or so, it's not long-running.
Each time it opens the same log file. Sounds like this isn't going to
do what I want.

Thanks for the clarification.
Feb 9 '07 #3
>Rotating should happen when the logging process creates the handler
before midnight and makes a logging call destined for that handler
after midnight.
ChrisAh, then maybe I'm expecting the wrong thing. The python code is
Chrisinvoked from cron every 10 minutes or so, it's not long-running.
ChrisEach time it opens the same log file. Sounds like this isn't
Chrisgoing to do what I want.

Right. Check out the logrotate facility on your system.

Skip
Feb 9 '07 #4
On 9 Feb, 14:14, s...@pobox.com wrote:
Right. Check out the logrotate facility on your system.
This can be used together with the WatchedFileHandler recently checked
into SVN trunk - this (Unix/Linux-only) handler checks to see if the
dev or inode have changed, and if they have (because of rotation by
e.g. logrotate), reopens the file before writing to it.

Regards,

Vinay Sajip

Feb 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian Hubling | last post by:
I'm trying to complete a rotating banner ad within a page I have. The rotating add has four images that rotate in three-second increments. I've got the images to rotate ok - but now I want to go...
1
by: Sandy Bremmer | last post by:
I have seen many Javascripts that rotate images with each load or refresh of the page but so far all I've found require hard coding the image filename into the script. Does anyone know of a script...
9
by: GGerard | last post by:
Using Access2000 I have an application that is running 24/7 and I would like this application to perform some routine housekeeping task at midnight. What would be an efficient way of...
3
by: Amy Smith | last post by:
Hello there, I am having a small problem which been challenging me for few days and need help or advice. I am trying to calculate the day-shift for employees based on the time they started and...
1
by: greg chu | last post by:
Hi, not sure who has done this. I want to set up a time interval that could be pass midnight. so people can enter 8AM to 8AM (pass midnight to 2nd day) 8AM to 2 AM (pass midnight to 2nd day)...
3
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In...
1
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in...
0
by: Gabriel Genellina | last post by:
En Thu, 05 Jun 2008 04:14:07 -0300, <Dominique.Holzwarth@ch.delarue.com> escribió: How do you use that class? raise MyInheritedError(...)? So you're creating the handler and logger and all...
2
by: =?Utf-8?B?YmlsbCB0aWU=?= | last post by:
How is midnight represented in ISO 8601 format? Thank you.
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.