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


Groups > comp.lang.python > #20613

logging with logging.config.fileConfig

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <sorsorday@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python:': 0.05; '%s"': 0.09; 'behavior:': 0.09; 'handlers': 0.09; 'received:10.50': 0.09; '%h:%m:%s': 0.16; 'handlers:': 0.16; 'subject:logging': 0.16; 'this:': 0.16; 'skip:[ 20': 0.19; 'received:209.85.210.174': 0.21; 'received:mail-iy0-f174.google.com': 0.21; 'skip:[ 10': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.29; 'weird': 0.29; "skip:' 10": 0.29; 'print': 0.29; 'config': 0.30; 'skip:% 10': 0.30; 'skip:% 20': 0.30; 'skip:l 30': 0.32; 'there': 0.33; 'file': 0.34; 'skip:k 20': 0.34; 'to:addr:python-list': 0.35; '...': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'subject:with': 0.37; 'received:209.85': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'header:Received:6': 0.61; 'here': 0.64; 'suspicious': 0.91
Received-SPF pass (google.com: domain of sorsorday@gmail.com designates 10.50.207.99 as permitted sender) client-ip=10.50.207.99;
Authentication-Results mr.google.com; spf=pass (google.com: domain of sorsorday@gmail.com designates 10.50.207.99 as permitted sender) smtp.mail=sorsorday@gmail.com; dkim=pass header.i=sorsorday@gmail.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=098CTa0VW5Q6YTlFt9TTsKQl957FeCf47jON0yi8BrQ=; b=qrxyifOseR49SEu3JAl2l5Th0AHc/H0uwD4Xr2bLySgX7WHNfRFIp87KL9OtSD2Jxa HxxfTkEQHm/2xiPSvr8ILo1ubrtU9rRTOVKfoL2pkTFdvcKZWjNLndgHKPncnbEV9ubl 81HEtzKGPZycsaRI8nh/KP0+qjdUdaPfQkUMg=
MIME-Version 1.0
Date Sun, 19 Feb 2012 12:23:21 -0800
Subject logging with logging.config.fileConfig
From Herman <sorsorday@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5955.1329683004.27778.python-list@python.org> (permalink)
Lines 56
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329683004 news.xs4all.nl 6951 [2001:888:2000:d::a6]:58612
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20613

Show key headers only | View raw


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:

[loggers]
keys=root,abc

[handlers]
keys=consoleHandler

[formatters]
keys=detailFormatter

[logger_root]
level=DEBUG
handlers=consoleHandler

[logger_abc]
level=DEBUG
handlers=consoleHandler
qualname=abc

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

[formatter_detailFormatter]
format=%(asctime)-15s %(levelname)s: %(filename)s:%(lineno)s: %(message)s
datefmt=%Y-%m-%d %H:%M:%S


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 ...

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


Thread

logging with logging.config.fileConfig Herman <sorsorday@gmail.com> - 2012-02-19 12:23 -0800

csiph-web