Python Logging: Specifying converter attribute of a log formatter in config file
bernhard.haslhofer at gmail.com
bernhard.haslhofer at gmail.com
Thu Aug 30 21:44:50 EDT 2012
I have the same problem and couldn't find a solution. It seems that converters can only be set programmatically?
On Thursday, August 30, 2012 6:38:27 AM UTC-4, Radha Krishna Srimanthula wrote:
> 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?
More information about the Python-list
mailing list