Keyerror addhandler

Steven Macintyre steven at steven.macintyre.name
Sun Apr 19 07:31:42 EDT 2009


Hi all,

I'm wondering if anyone can assist me with this as I am very confused about
it now.

I am getting the following error;

Traceback (most recent call last):
  File "/usr/lib/python2.4/logging/config.py", line 191, in fileConfig
    logger.addHandler(handlers[hand])
KeyError: 'handler_mylogfileHandler'

My code:

import logging
import logging.config
import logging.handlers

#parse config file
logging.config.fileConfig("logging.conf")

#create logger
logger = logging.getLogger("pythonacro")

my config:

[loggers]
keys=root,pythonacro

[handlers]
keys=consoleHandler,mylogfileHandler

[formatters]
keys=simpleFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[logger_pythonacro]
level=DEBUG
handlers=consoleHandler,mylogfileHandler
propagate=1
qualname=pythonacro

[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)

[handler_mylogfileHandler]
class=RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('python_acro.log', 'a', 125829120, 5)
filename=python_acro.log
mode=a

[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=

As far as I can tell, this is correct according to logging-config-fileformat
and documentation found on google.

Any ideas?

Many thanks

Steven






More information about the Python-list mailing list