473,387 Members | 1,619 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,387 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 23468
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.