I'm trying to modify the output of my Python logger to show the process ID.
Two ways I've tried:
import logging
FORMAT = "%(asctime)s %(process)s %(thread)s: %(message)s"
logging.basicConfig(format=FORMAT)
logger = logging.getLogger('my_logger')
and
import logging
FORMAT = "%(asctime)s %(process)s %(thread)s: %(message)s"
logger = logging.getLogger('my_logger')
handler = logger.handlers[0]
handler.setFormatter(logging.Formatter(FORMAT))
Nada. First one doesn't change the format. Second one throws an index error when I try to access logger.handlers[0].
I don't want to write my own handler, just modify the format on the default handler. Is there an easy way?