Is it possible and how to set the logging timezone to GMT?
(i.e. the %(asctime)s
parameter in the format)
Python time asctime() Method Pythom time method asctime() converts a tuple or struct_time representing a time as returned by gmtime() or localtime() to a 24-character string of the following form: 'Tue Feb 17 23:21:05 2009'.
Although logging module is thread-safe, it's not process-safe. If you want multiple processes to write to the same log file, then you have to manually take care of the access to your file.
logging.Formatter.converter = time.gmtime
(documented in the docstring of logging.Formatter.formatTime
)
Just setting logging.Formatter.converter = time.gmtime
is ineffective for me in Python 2.5.
So I created a child class with it set, and use that in place of logging.Formatter:
class UTCFormatter(logging.Formatter): converter = time.gmtime
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With