What is Python’s default logging formatter?

The default format is located here which is:

BASIC_FORMAT = "%(levelname)s:%(name)s:%(message)s"  

The Format code will tell you how you can customize it. Here is one example on how you can customize it.

import sys
import logging

logging.basicConfig(
    level=logging.DEBUG,
    format="[%(asctime)s] %(levelname)s [%(name)s.%(funcName)s:%(lineno)d] %(message)s",
    datefmt="%d/%b/%Y %H:%M:%S",
    stream=sys.stdout)

logging.info("HEY")

Which results in:

[26/May/2013 06:41:40] INFO [root.<module>:1] HEY

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)