You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage.md
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -137,17 +137,39 @@ Structured logging via [Structlog](https://www.structlog.org/) with automatic tr
137
137
138
138
### Setup
139
139
140
-
Logging is configured by calling `build_logging_dict()` in your settings. Django applies it through the standard `LOGGING` setting — no magic, no auto-configuration.
140
+
Call `build_logging_dict()` in each settings file. The defaults are keyed off `DEBUG`, so most of the difference between environments is handled automatically.
141
+
142
+
`LOGGING_CONFIG = None` is required in every settings file. Without it Django applies its own default handlers at startup, which causes duplicate access logs and Werkzeug's color handler showing up alongside structlog output.
143
+
144
+
**`settings/local.py`**
145
+
146
+
```python
147
+
from django_o11y.logging.config import build_logging_dict
148
+
149
+
LOGGING_CONFIG=None
150
+
LOGGING= build_logging_dict()
151
+
# DEBUG=True: console format, colorized, file output to /tmp/django-o11y/django.log
152
+
```
153
+
154
+
**`settings/production.py`**
141
155
142
156
```python
143
-
# settings.py
144
157
from django_o11y.logging.config import build_logging_dict
145
158
146
-
LOGGING_CONFIG=None# prevent Django applying its DEFAULT_LOGGING first
159
+
LOGGING_CONFIG=None
147
160
LOGGING= build_logging_dict()
161
+
# DEBUG=False: JSON format, no file output
148
162
```
149
163
150
-
`LOGGING_CONFIG = None` is required. Without it Django applies its own default handlers before your app config is ready, which causes duplicate access logs and Werkzeug's color handler showing up alongside structlog output.
164
+
**`settings/test.py`**
165
+
166
+
```python
167
+
from django_o11y.logging.config import build_logging_dict
0 commit comments