^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\s-\s(\w+)\s-\s([\w.]+)\s-\s(.+)
^\d
yyyy-MM-dd HH:mm:ss
- Time: 1
- Severity: 3
- Category: 2
fmt = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s", "%Y-%m-%d %H:%M:%S")
logging.getLogger().setFormatter(fmt)
# or simply
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=[logging.StreamHandler(), logging.FileHandler("stuff.log")],
)