Log Django errors to the console so kubectl logs shows 500 tracebacks

This commit is contained in:
sajeyks 2026-11-05 13:39:45 +03:00
commit 30bc473210

View file

@ -710,6 +710,24 @@ if ENABLE_LOGGING:
'handlers': handlers_dict,
'loggers': loggers_dict
}
else:
# Django only prints errors (tracebacks of 500s) to the console when DEBUG is on, so
# send them to stderr, where "kubectl logs" and "docker compose logs" show them.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'standard': {
'format': '%(asctime)s %(levelname)-8s [%(name)s] %(message)s',
}
},
'handlers': {
'console': {'class': 'logging.StreamHandler', 'formatter': 'standard'},
},
'loggers': {
'django': {'handlers': ['console'], 'level': 'WARNING'},
},
}
TEST_MANAGE_SSH_KEY_PUBKEY = env('TEST_MANAGE_SSH_KEY_PUBKEY')
TEST_MANAGE_SSH_KEY_HOST = env('TEST_MANAGE_SSH_KEY_HOST')