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.
|