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


Groups > comp.lang.python > #20614 > unrolled thread

Re: logging with logging.config.fileConfig

Started byMRAB <python@mrabarnett.plus.com>
First post2012-02-19 21:07 +0000
Last post2012-02-19 21:07 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: logging with logging.config.fileConfig MRAB <python@mrabarnett.plus.com> - 2012-02-19 21:07 +0000

#20614 — Re: logging with logging.config.fileConfig

FromMRAB <python@mrabarnett.plus.com>
Date2012-02-19 21:07 +0000
SubjectRe: logging with logging.config.fileConfig
Message-ID<mailman.5956.1329685596.27778.python-list@python.org>
On 19/02/2012 20:23, Herman wrote:
> I tried to use file to config my logger and I got a weird situation
> that each message is outputted twice...
> Here is my scenario:
> python: 2.6
>
> file abc_logging.conf:
>
[snip]
> [logger_abc]
> level=DEBUG
> handlers=consoleHandler
> qualname=abc

Add this line to stop the logging message from being propagated to
higher level (ancestor) loggers:

propagate=0

[snip]
>
>
> Then in my program, i config the file with this:
>
> SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
> logging.config.fileConfig(SCRIPT_DIR + os.path.sep + 'abc_logging.conf')
> LOG = logging.getLogger('abc')
>
>
> I tried to print out the logger handlers with this:
>   print("*"*10)
>   print("number of handlers: %s" % len(LOG.handlers))
>   print(LOG.handlers)
>   LOG.debug(sql)
>
> But there is no suspicious behavior:
>
> **********
> number of handlers: 1
> [<logging.StreamHandler instance at 0xf23518>]
> 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ...
> 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ...

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web