RotatingFileHandler key error when parsing a logging config file

Discussion in 'Python' started by jordilin, Dec 21, 2009.

  1. jordilin

    jordilin Guest

    Hi,
    I've a config for logging where I set up a file rotation with
    handlers.RotatingFileHandler and when the app parses the logging
    config it says keyError when trying to parse that section
    ('RotatingFileHandler' is not defined). Curiously enough, I can do
    import logging and from logging.handlers import RotatingFileHandler.

    Example:

    [handlers]
    keys=handlers.RotatingFileHandler

    [formatters]
    keys=simpleFormatter

    [logger_root]
    level=DEBUG
    handlers=handlers.RotatingFileHandler

    [handler_handlers.RotatingFileHandler]
    class=handlers.RotatingFileHandler
    level=DEBUG
    formatter=simpleFormatter


    I'm using python 2.4 in the servers. I'm having this in a particular
    one, which seems like there must be some kind of configuration error.
    Any suggestions,
    Thanks
    jordilin, Dec 21, 2009
    #1
    1. Advertising

  2. jordilin wrote:
    > Hi,
    > I've a config for logging where I set up a file rotation with
    > handlers.RotatingFileHandler and when the app parses the logging
    > config it says keyError when trying to parse that section
    > ('RotatingFileHandler' is not defined). Curiously enough, I can do
    > import logging and from logging.handlers import RotatingFileHandler.
    >
    > Example:
    >
    > [handlers]
    > keys=handlers.RotatingFileHandler
    >
    > [formatters]
    > keys=simpleFormatter
    >
    > [logger_root]
    > level=DEBUG
    > handlers=handlers.RotatingFileHandler
    >
    > [handler_handlers.RotatingFileHandler]
    > class=handlers.RotatingFileHandler
    > level=DEBUG
    > formatter=simpleFormatter
    >
    >
    > I'm using python 2.4 in the servers. I'm having this in a particular
    > one, which seems like there must be some kind of configuration error.
    > Any suggestions,
    > Thanks
    >

    I'm not using config files, but by looking at the documentation, I would
    suggest to use another name for your handler.

    [handler_foo]
    class=handlers.RotatingFileHandler
    level=DEBUG
    formatter=simpleFormatter


    just name it foo for test purpose, dotted names may not be supported.
    Also I would not not the exact same name as
    logging.handlers.RotatingFileHandler, your risk some name collision
    wetween the structure you have created and the logging module class.


    JM
    Jean-Michel Pichavant, Dec 22, 2009
    #2
    1. Advertising

  3. jordilin

    Vinay Sajip Guest

    On Dec 21, 9:33 pm, jordilin <> wrote:
    > Hi,
    >  I've a config forloggingwhere I set up a file rotation with
    > handlers.RotatingFileHandler and when the app parses thelogging
    > config it says keyError when trying to parse that section
    > ('RotatingFileHandler' is not defined). Curiously enough, I can do
    > importloggingand fromlogging.handlers import RotatingFileHandler.
    >
    > Example:
    >
    > [handlers]
    > keys=handlers.RotatingFileHandler
    >
    > [formatters]
    > keys=simpleFormatter
    >
    > [logger_root]
    > level=DEBUG
    > handlers=handlers.RotatingFileHandler
    >
    > [handler_handlers.RotatingFileHandler]
    > class=handlers.RotatingFileHandler
    > level=DEBUG
    > formatter=simpleFormatter
    >
    > I'm using python 2.4 in the servers. I'm having this in a particular
    > one, which seems like there must be some kind of configuration error.
    > Any suggestions,
    > Thanks


    Can you show the error message/traceback which you're getting? With
    earlier versions of the logging package, handler class names were
    evaluated in the context of the logging module (so
    handlers.RotatingFileHandler should work). Later versions (than 2.4)
    will try to resolve using normal import mechanisms, so
    foo.bar.MyHandler should work.

    It does seem like a configuration error (esp. if this same code works
    on other machines running Python 2.4), but it's hard to say what it is
    with the information you've provided so far.

    Regards,

    Vinay Sajip
    Vinay Sajip, Dec 22, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rob Cranfill
    Replies:
    12
    Views:
    7,020
    Vinay Sajip
    Mar 20, 2005
  2. flupke
    Replies:
    7
    Views:
    953
    Vinay Sajip
    Jul 2, 2006
  3. Roopesh

    RotatingFileHandler Error

    Roopesh, Dec 29, 2006, in forum: Python
    Replies:
    0
    Views:
    574
    Roopesh
    Dec 29, 2006
  4. Replies:
    4
    Views:
    478
    Vinay Sajip
    May 10, 2007
  5. Gabriel Genellina

    Re: RotatingFileHandler - ShouldRollover error

    Gabriel Genellina, Apr 20, 2008, in forum: Python
    Replies:
    0
    Views:
    441
    Gabriel Genellina
    Apr 20, 2008
Loading...

Share This Page