Format changes first
logging.<severity>("message")
In other words, when you set the format in the first example, you do not need to purchase a separate instance of the log, you can just use logging . However, it may have undesirable effects if any other modules you use also use logging .
If you want to change the format of your individual registrar, you can use the following example:
from logging import StreamHandler, Formatter FORMAT = '%(asctime)-15s %(levelname)-6s %(message)s' DATE_FORMAT = '%b %d %H:%M:%S' formatter = Formatter(fmt=FORMAT, datefmt=DATE_FORMAT) handler = StreamHandler() handler.setFormatter(formatter) logger = logging.getLogger(__name__) logger.addHandler(handler)
source share