[ python-Bugs-982049 ] Relative Path causing crash in RotatingFileHandler

SourceForge.net noreply at sourceforge.net
Thu Jul 8 11:43:52 CEST 2004


Bugs item #982049, was opened at 2004-06-29 16:34
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=982049&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: David London (groodude)
Assigned to: Vinay Sajip (vsajip)
Summary: Relative Path causing crash in RotatingFileHandler

Initial Comment:
When using the RotatingFileHandler class, if the
working directory is changed after the logging is setup
and a relative file name has been used to set up the
handler, python will crash when a rollover is attempted.
In my application, I set up the logger first (using a
config file) and then I start reading the config file
for the application. This is done so that I can log any
errors found within the application config file.
However, if a certain option is set, then the
application has to change the working directory. But
since the file name that I have included is relative,
when the logger attempts to rollover the file, it
crashes since the log file can no longer be found
within the current directory. 

Is this the desired behaviour (i.e. does the logger
expect to have absolute paths)? If so, this would be a
good thing to add to the documentation (along with an
example of a RotatingFileHandler configuration in
section 6.28.7.2).
It seems to make more sense that when a file name is
passed in, the absolute path be stored.

Even if this is the desired behaviour, I think that an
example of the RotatingFileConfig handler should be
included in the configuration section, complete with
values for the maxbytes and the number of back ups.


----------------------------------------------------------------------

>Comment By: Vinay Sajip (vsajip)
Date: 2004-07-08 09:43

Message:
Logged In: YES 
user_id=308438

No, it's not the desired behaviour. I will put a fix into CVS: in 
the package's __init__.py, change the line in 
FileHandler.__init__ to

        self.baseFilename = os.path.abspath(filename)

and the RotatingFileHandler will then use absolute paths for 
its log files.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2004-07-08 01:38

Message:
Logged In: YES 
user_id=33168

Vinay, do you have any comments?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=982049&group_id=5470


More information about the Python-bugs-list mailing list