Skip to content

Commit 3682f88

Browse files
authored
docs: explain how to enable INFO logs for posthog modules (#13920)
1 parent 53417f7 commit 3682f88

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

contents/handbook/engineering/conventions/backend-coding.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,23 @@ will produce:
3535
```
3636
As you can see above, the log contains all the information needed to understand the app behaviour.
3737

38+
##### Enabling INFO logs for your module
39+
40+
By default, most `posthog.*` loggers only output WARNING and above. This keeps production logs clean but means your `logger.info()` calls won't appear.
41+
42+
To enable INFO logging for a specific module, add it to `posthog/settings/logs.py`:
43+
44+
```python
45+
"loggers": {
46+
# ... existing loggers ...
47+
"posthog.tasks.my_module": {"level": "INFO", "handlers": ["console"], "propagate": False},
48+
}
49+
```
50+
51+
Note: calling `logger.setLevel(logging.INFO)` in your code doesn't work with structlog - you must add the config entry above.
52+
53+
Celery task lifecycle events (`task_started`, `task_succeeded`, etc.) are logged automatically by `django-structlog` at INFO level and are already enabled.
54+
3855
##### Security
3956
Don’t log sensitive information. Make sure you never log:
4057

0 commit comments

Comments
 (0)