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 -- http://mail.python.org/mailman/listinfo/python-list