This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Relative Path causing crash in RotatingFileHandler
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: groodude, nnorwitz, paul.moore, vinay.sajip
Priority: normal Keywords:

Created on 2004-06-29 16:34 by groodude, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg21351 - (view) Author: David London (groodude) Date: 2004-06-29 16:34
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.
msg21352 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-07-08 01:38
Logged In: YES 
user_id=33168

Vinay, do you have any comments?
msg21353 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2004-07-08 09:43
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.
msg21354 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2004-07-10 18:35
Logged In: YES 
user_id=113328

I've just checked, and this has now been applied in CVS -
should the bug be closed?
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40478
2004-06-29 16:34:21groodudecreate