docker-django-example icon indicating copy to clipboard operation
docker-django-example copied to clipboard

Add `LOG_LEVEL` env var?

Open SHxKM opened this issue 2 years ago • 3 comments

Really enjoying the quality of this, I was wondering if it'd be handy to have a LOG_LEVEL env var (detached from DEBUG) that would allow Django to output logs when running with gunicorn in production.

SHxKM avatar Jan 27 '24 12:01 SHxKM

Thanks.

Gunicorn is also used in development. There's a Gunicorn loglevel config option you can add that could be associated with a WEB_LOG_LEVEL env var that we add. Is that what you were thinking? Alternatively there's https://docs.djangoproject.com/en/5.0/topics/logging.

nickjj avatar Jan 27 '24 12:01 nickjj

Just realized what I was really referring to is having Django log level be controlled by an environment variable.

SHxKM avatar Jan 27 '24 19:01 SHxKM

Django has different log levels for different components of its framework. For example here's the default logging settings: https://docs.djangoproject.com/en/5.0/ref/logging/#default-logging-configuration

We would have to override those and reference an env variable. Likely the handlers.console and loggers.django sections would be overwritten. The rest can remain hard coded because this project doesn't use the django.server and having admin emails only report errors is a good default for now.

nickjj avatar Jan 28 '24 13:01 nickjj