Re: logging producing redundant entries
- From: Kent Johnson <kent@xxxxxxxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 13:50:51 -0500
Jed Parsons wrote:
Thanks, Peter and alex23,
The metalog test shows that the code is only being executed once at a time.
And if I take those lines and put them in a shell script (fixing the FileHandler - sorry about the bad copy there), they work as expected, producing a single log entry.
So I'm left with:
- logging code that works properly in isolation in a shell script
- zope extension code that gets called only once (metalog test)
- logging code produces multiple entries when executed in extension
- logging code seems to produce more and more entries over time
Am I somehow accumulating a growing list of loggers by having this code at the top of a zope Extension? If I cause the extension to be re-evaluated, do I somehow attach another logger? (I'm grasping at straws...)
It sounds like Zope is reloading your extension. Each time it is reloaded you will attach another logger.
I've tried the following to only call getLogger once, but it doesn't seem to help:
try:
_logger
except NameError:
_logger = logging.getLogger('login')
etc...
No, that won't work if it really is a reload, _logger will never be defined. Can you put the logging setup somewhere else, in a module that is only loaded once? Or inspect _logger.handlers to see if it already contains a FileHandler to your log file, and only add it if it is not there already.
Kent
.
- References:
- logging producing redundant entries
- From: Jed Parsons
- Re: logging producing redundant entries
- From: Peter Otten
- Re: logging producing redundant entries
- From: Jed Parsons
- logging producing redundant entries
- Prev by Date: exception handling in Tkinter
- Next by Date: Re: any() and all() on empty list?
- Previous by thread: Re: logging producing redundant entries
- Next by thread: Newbie: splitting dictionary definition across two .py files
- Index(es):
Relevant Pages
|