root@e9076f0e6e52:/ws1/TOT/usr.src/cpx# date
Thu Jan 10 13:04:38 IST 2019
root@e9076f0e6e52:/ws1/TOT/usr.src/cpx# python3 log_gmt_timezone.py
2019-01-10 07:34:40,428 - DEBUG - [log_gmt_timezone.py:<module>:14] (MainThread) Hello world
root@e9076f0e6e52:/ws1/TOT/usr.src/cpx# cat log_gmt_timezone.py
import logging
import time
# Configuring standard output log handler
NSTRITON_LOG_FORMAT = '%(asctime)s - %(levelname)s - [%(filename)s:%(funcName)s:%(lineno)d] (%(threadName)s) %(message)s'
logger = logging.getLogger('docker_netscaler')
stdloghandler = logging.StreamHandler()
logformatter = logging.Formatter(fmt=NSTRITON_LOG_FORMAT)
stdloghandler.setFormatter(logformatter)
logging.Formatter.converter = time.gmtime
logger.addHandler(stdloghandler)
logger.setLevel(logging.DEBUG)
logger.debug("Hello world")
root@e9076f0e6e52:/ws1/TOT/usr.src/cpx#
https://docs.python.org/3/howto/logging.html
https://stackoverflow.com/questions/6321160/python-logging-how-to-set-time-to-gmt/10267199