Problem with TimedRotatingFileHandler

Dominique.Holzwarth at Dominique.Holzwarth at
Thu Jun 5 09:14:07 CEST 2008

Hi everyone

I'm trying to use python's logging mechanism to write exception data into a log file with the TimedRotatingFileHandler but the rotating of the file is not working...
Here's a bit of sample code of what I'm doing (just the interessting part of it ;-)):

import logging
import logging.handlers as handlers
class MyError(Exception):

    fileName = os.path.join(os.path.dirname(__file__), 'Error.log')

    def __init__(self):
        fileHandler = handlers.TimedRotatingFileHandler(MyError.fileName, when='m', interval=1, backupCount=1)
        formatter = logging.Formatter('\n%(name)-12s: <%(asctime)s> %(levelname)-8s %(message)s')
        ## Reference to the logger object
        self.logger = logging.getLogger('FileLogger')

class MyInheritedError(MyError):
    def __init__(self):
        self.logger.error("some stupid text :-)")

The error classes do write into the log file, however there's no rotating. No new file is created (and old ones renamed) nor are there any old log entries deleted/replaced...
Does anyone have any idea what I could be missing? Might it be a problem due to the fact that these classes inherit from "Exception"?

Would be really cool if some1 could help me :)

This e-mail and any files attached are strictly confidential, may be legally
privileged and are intended solely for the addressee. If you are not the
intended recipient please notify the sender immediately by return email and
then delete the e-mail and any attachments immediately.

The views and or opinions expressed in this e-mail are not necessarily the
views of De La Rue plc or any of its subsidiaries and the De La Rue Group
of companies, their directors, officers and employees make no representation
about and accept no liability for its accuracy or completeness.

You should ensure that you have adequate virus protection as the De La Rue
Group of companies do not accept liability for any viruses.

De La Rue plc Registered No.3834125, De La Rue Holdings plc Registered
No 58025 and De La Rue International Limited Registered No 720284 are all
registered in England with their registered office at:
De La Rue House, Jays Close, Viables, Hampshire RG22 4BS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list