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


Groups > comp.lang.python > #28098

Python Logging: Specifying converter attribute of a log formatter in config file

Received by 10.66.83.40 with SMTP id n8mr654121pay.42.1346323106989; Thu, 30 Aug 2012 03:38:26 -0700 (PDT)
Received by 10.68.237.163 with SMTP id vd3mr886362pbc.9.1346323106973; Thu, 30 Aug 2012 03:38:26 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!4no28038892pbn.1!news-out.google.com!a8ni100059889pbd.1!nntp.google.com!4no28038890pbn.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Thu, 30 Aug 2012 03:38:26 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=27.34.244.98; posting-account=Hk1meAoAAABUg4i8CFG9rfjPzBhrH-BF
NNTP-Posting-Host 27.34.244.98
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <97b8c5f2-eaa9-456a-b766-146ac65b879e@googlegroups.com> (permalink)
Subject Python Logging: Specifying converter attribute of a log formatter in config file
From srimanthula.radhakrishna@gmail.com
Injection-Date Thu, 30 Aug 2012 10:38:26 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:28098

Show key headers only | View raw


I'd like to have all timestamps in my log file to be UTC timestamp. When specified through code, this is done as follows:

myHandler = logging.FileHandler('mylogfile.log', 'a')
formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(name)-15s:%(lineno)4s: %(message)-80s')
formatter.converter = time.gmtime

myLogger = logging.getLogger('MyApp')
myLogger.addHandler(myHandler)


I'd like to move away from the above 'in-code' configuration to a config file based mechanism.

Here's the config file section for the formatter:

[handler_MyLogHandler]
args=("mylogfile.log", "a",)
class=FileHandler
level=DEBUG
formatter=simpleFormatter

Now, how do I specify the converter attribute (time.gmtime) in the above section?

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


Thread

Python Logging: Specifying converter attribute of a log formatter in config file srimanthula.radhakrishna@gmail.com - 2012-08-30 03:38 -0700
  Re: Python Logging: Specifying converter attribute of a log formatter in config file Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-09-16 01:07 -0700

csiph-web