NTEventLogHandler not logging `info'?

Vinay Sajip vinay_sajip at yahoo.co.uk
Thu Sep 22 17:21:48 CEST 2005

Jaime Wyant wrote:
> This code doesn't seem to do what I think it should do:
> # python 2.3.2
> # not sure of my win32 extensions version
> import logging
> from logging.handlers import NTEventLogHandler
> logger = logging.getLogger("testlogger")
> handler = NTEventLogHandler("testlogger")
> logger.addHandler(handler)
> logger.info("This is a test")
> I expected to see an `information' message in my `Application' event
> log.  Any ideas?

By default, the logger's level is WARNING, because you haven't
explicitly set a level and the level inherited from the parent logger
is WARNING (this is the default value for the root logger level). So if
you add a line before the logger.info() call:

logger.setLevel(logging.INFO) # or you can use logging.DEBUG

Then you should see an entry appear in the NT Event log.

More information about the Python-list mailing list