简体   繁体   中英

How to python logger format

I have python 2.7.5(linux) and 2.7.12(anaconda, windows) installed. My logger looks like:

formatter = logging.Formatter( %(w)s - %(k)s - %(v)s',
                                  datefmt='%d/%b/%Y:%H:%M:%S %z')

Linux:

- 10/May/2017:07:15:36 +0000 -

Windows(anaconda)

- 10/May/2017:16:23:15 Central Europe Daylight Time -

Anybody has an idea how to get rid of "Central Europe Daylight Time" and have +0000 instead ????

Actually the problem isn't with your code. Unfortunately the libraries under Windows don't support %z flag, and Python relies on those libraries.

From the documentation :

The use of %Z is now deprecated, but the %z escape that expands to the preferred hour/minute offset is not supported by all ANSI C libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM