Python logging: use milliseconds in time format

后端 未结 10 1812
不知归路
不知归路 2020-12-02 05:36

By default logging.Formatter(\'%(asctime)s\') prints with the following format:

2011-06-09 10:54:40,638

where 638 is the milli

10条回答
  •  無奈伤痛
    2020-12-02 05:59

    Adding msecs was the better option, Thanks. Here is my amendment using this with Python 3.5.3 in Blender

    import logging
    logging.basicConfig(level=logging.DEBUG, format='%(asctime)s.%(msecs)03d %(levelname)s:\t%(message)s', datefmt='%Y-%m-%d %H:%M:%S')
    log = logging.getLogger(__name__)
    log.info("Logging Info")
    log.debug("Logging Debug")
    

提交回复
热议问题