How to properly configure Python logging using dictConfig with JSON? or Best practices for setting up

14 Replies, 868 Views

Yo, here’s a lazy trick:

1. Set up a basic config in code first (just to test).
2. Once it works, *convert* it to JSON using `json.dumps()`.

Like:

```python
import logging.config
import json

config = {
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
"level": "DEBUG"
}
}
}

print(json.dumps(config, indent=4))
```

Now you’ve got a JSON template to tweak.

Also, +1 for `logging_tree`—it’s clutch for debugging.

Messages In This Thread



Users browsing this thread: 1 Guest(s)