Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4369

Re: (beginner) logging config not working

From Unknown Moss <unknownmoss@gmail.com>
Newsgroups comp.lang.python
Subject Re: (beginner) logging config not working
Date 2011-04-30 13:58 -0700
Organization http://groups.google.com
Message-ID <8e3a35fd-540d-49d0-a40c-b5c4b620923e@s41g2000prb.googlegroups.com> (permalink)
References <3aa863d1-8e69-42c2-9cfc-c0d9a9de14ec@d19g2000prh.googlegroups.com> <ipg5hp$6m0$1@solani.org>

Show all headers | View raw


On Apr 29, 10:09 pm, Peter Otten <__pete...@web.de> wrote:
> Unknown Moss wrote:
> > Hi
>
> > This is a beginner question. Thanks for the hand.
>
> > I've been asked to maintain some poorly constructed python code.
> > Logging is weak. Getting it to work with python logging
> > programmatically was easy.
>
> > However, I'd like to refactor all the logging code into configuration
> > since I see the need for other handlers in the future (syslog and
> > possibly email).
>
> > For now I just want to get console and log file working, but I'm
> > having problems with the log file. I'm trying some test code. Here's
> > my test script (logging_example.py):
>
> > import logging
> > import logging.config
>
> > def main():
> >     logging.config.fileConfig("logging.conf")
> >     logging.debug("debug check")
>
> The above is a shortcut for
>
> root = logging.getLogger("")
> root.debug("debug check")
>
> i. e. you are logging to the root logger. According to your config file
> messages sent to the root logger are only handled by the console handler:
>
> > [logger_root]
> > level=NOTSET
> > handlers=console
>
> You can either change that by adding the file handler to the list of
> handlers for the root logger
>
> handlers=console,file
>
> in the config file or by directing your logging messages to "mylogger" with
>
> mylogger = logging.getLogger("mylogger")
> mylogger.debug("debug check")
>
> Note that loggers are organized in a tree; messages sent to mylogger will be
> propagated upwords to the root logger by default.

Thanks you Peter. That worked perfectly. It points out that I'm not
really understanding the python logging concepts yet. I'll search for
more details. I need pictures.  :-)

Thanks again.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

(beginner) logging config not working Unknown Moss <unknownmoss@gmail.com> - 2011-04-29 17:17 -0700
  Re: (beginner) logging config not working Peter Otten <__peter__@web.de> - 2011-04-30 07:09 +0200
    Re: (beginner) logging config not working Unknown Moss <unknownmoss@gmail.com> - 2011-04-30 13:58 -0700
    Re: (beginner) logging config not working Unknown Moss <unknownmoss@gmail.com> - 2011-04-30 13:58 -0700

csiph-web