[ python-Bugs-1752539 ] RotatingFileHandler.doRollover behave wrong vs. log4j's
SourceForge.net
noreply at sourceforge.net
Mon Jul 16 05:05:51 CEST 2007
Bugs item #1752539, was opened at 2007-07-12 18:34
Message generated for change (Comment added) made by jinq0123
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1752539&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jin Qing (jinq0123)
Assigned to: Vinay Sajip (vsajip)
Summary: RotatingFileHandler.doRollover behave wrong vs. log4j's
Initial Comment:
RotatingFileHandler.doRollover() will raise exception on rename() and cause all the subsequent log messages lost.
But log4j is better. It ignore the rename() error and reset the log file.
I read "[ 979252 ] Trap OSError when calling RotatingFileHandler.doRollover ( https://sourceforge.net/tracker/index.php?func=detail&aid=979252&group_id=5470&atid=105470 )", and think David London (groodude)'s solution is closer to log4j.
At least, python logging implementation should follow log4j's behavior, or improve it, such as only discard the current one message.
logging should be easy to use.
----------------------------------------------------------------------
>Comment By: Jin Qing (jinq0123)
Date: 2007-07-16 11:05
Message:
Logged In: YES
user_id=692544
Originator: YES
Calling handleError is a workaround, not the correct way of log4j. This
is Python, and should be easy to use. Subclass & override is a little hard
to use. If it is required for every users to subclass or patch
RotatingFileHandler to use it, so why not patch it in the released version?
Everybody expect logging module has a behavior in common with log4j.
The exception of rename() is real. rename() fails if the source file is
locked. I found UltraEdit will lock file. Others say tail -f will lock file
too.
In C++ or java, rename() just returns error, but Python raises exception
and causes different logging behavior. Why not just ignore the exception of
rename()? Or try rename() and finally open the log file?
By the way, log4j is much more robust on opening the log file. It will
create the parent directories and retry if open failed. Python logging
should learn from log4j.
----------------------------------------------------------------------
Comment By: Vinay Sajip (vsajip)
Date: 2007-07-14 01:51
Message:
Logged In: YES
user_id=308438
Originator: NO
The system was modified in the fix for #979252 to call handleError when an
error occurred during the emit() processing.
I am travelling and do not have access to my systems at the moment, so
cannot commit to look at this just yet.
For now, users are free to subclass the RotatingFileHandler and override
handleError however they want, including implementing groodude's solution,
which (as he says in his comments) is a band-aid to cover unknown error
conditions. Since there is no good reason for the rename to fail, I would
suggest to the poster to see if he can find out why he is getting exception
on rename; and I will give this some thought when I next have time, but
that will not be just yet, and until then I suggest using the
subclass/override approach.
I'll leave it open to remind me to look at it, but I believe the
workarounds I have suggested are not unreasonable for now.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2007-07-13 11:47
Message:
Logged In: YES
user_id=33168
Originator: NO
Vinay, could you take a look? Thanks.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1752539&group_id=5470
More information about the Python-bugs-list
mailing list