[b]"How to properly configure Python logging using dictConfig with JSON?"[/b] or [b]"Best practices for setting up

14 Replies, 744 Views

Ugh, I *hated* this too until I found a template. Here’s a barebones JSON config that works for me:

```json
{
"version": 1,
"formatters": {
"simple": {
"format": "%(levelname)s: %(message)s"
}
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "simple"
}
},
"root": {
"handlers": ["console"],
"level": "INFO"
}
}
```

Save it as `log_config.json` and load it like the other reply said.

Pro tip: Use `"level": "WARNING"` if you *really* wanna cut the noise.

Messages In This Thread



Users browsing this thread: 1 Guest(s)