[Django] #34236: Django logging when in production with Gunnicron

15 views
Skip to first unread message

Django

unread,
Dec 31, 2022, 5:44:41 AM12/31/22
to django-...@googlegroups.com
#34236: Django logging when in production with Gunnicron
-----------------------------------------+-------------------------
Reporter: Derek | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.1
Severity: Normal | Keywords: logging
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+-------------------------
I was trying to configure access logs using Django logging as per
documentation https://docs.djangoproject.com/en/4.1/howto/logging/
I wanted to collect all access logs from INFO. It works perfectly when in
development mode. However, when I switched to Gunnicron in production, I
got only warnings and higher status logs.

After a bit of searching, I have found this ticket below, which kind of
summarises this behaviour.
https://code.djangoproject.com/ticket/33897
I think the documentation should say that once in production with
Gunnicorn, there are no access logs with INFO status from the Django
logger.

--
Ticket URL: <https://code.djangoproject.com/ticket/34236>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 31, 2022, 11:18:39 AM12/31/22
to django-...@googlegroups.com
#34236: Django logging when in production with Gunnicron
-------------------------------+--------------------------------------

Reporter: Derek | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.1
Severity: Normal | Resolution:

Keywords: logging | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Derek:

Old description:

> I was trying to configure access logs using Django logging as per
> documentation https://docs.djangoproject.com/en/4.1/howto/logging/
> I wanted to collect all access logs from INFO. It works perfectly when in
> development mode. However, when I switched to Gunnicron in production, I
> got only warnings and higher status logs.
>
> After a bit of searching, I have found this ticket below, which kind of
> summarises this behaviour.
> https://code.djangoproject.com/ticket/33897
> I think the documentation should say that once in production with
> Gunnicorn, there are no access logs with INFO status from the Django
> logger.

New description:

I was trying to configure access logs using Django logging as per
documentation https://docs.djangoproject.com/en/4.1/howto/logging/
I wanted to collect all access logs from INFO. It works perfectly when in
development mode. However, when I switched to Gunnicron in production, I
got only warnings and higher status logs.

After a bit of searching, I have found this ticket below, which kind of
summarises this behaviour.
https://code.djangoproject.com/ticket/33897
I think the documentation should say that once in production with
Gunnicorn, there are no access logs with INFO status from the Django
logger.

My logging configuration is as follow:


{{{
LOGGING = {
'version': 1, # the dictConfig format version
'disable_existing_loggers': False, # retain the default loggers

'handlers': {
'rotatingFile': {
'level': LOG_LEVEL,
'class': 'logging.handlers.RotatingFileHandler',
'formatter': 'verbose',
'maxBytes': LOG_MAX_SIZE,
'backupCount': LOG_NUMBER_OF_FILES,
'filename': LOG_LOCATION,
}
},
'loggers': {
# '': {
# 'handlers': ['rotatingFile'],
# 'level': LOG_LEVEL,
# },
'root': {
'handlers': ['rotatingFile'],
'level': LOG_LEVEL,
},

},
'formatters': {
'verbose': {
'format': '{asctime} {levelname} {name} {module} {process:d}
{thread:d} {message}',
'style': '{',
},
},
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34236#comment:1>

Django

unread,
Dec 31, 2022, 11:19:17 AM12/31/22
to django-...@googlegroups.com
#34236: Django logging when in production with Gunnicron
-------------------------------+--------------------------------------
Reporter: Derek | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.1
Severity: Normal | Resolution:
Keywords: logging | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Derek:

Old description:

> I was trying to configure access logs using Django logging as per
> documentation https://docs.djangoproject.com/en/4.1/howto/logging/
> I wanted to collect all access logs from INFO. It works perfectly when in
> development mode. However, when I switched to Gunnicron in production, I
> got only warnings and higher status logs.
>
> After a bit of searching, I have found this ticket below, which kind of
> summarises this behaviour.
> https://code.djangoproject.com/ticket/33897
> I think the documentation should say that once in production with
> Gunnicorn, there are no access logs with INFO status from the Django
> logger.
>

New description:

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34236#comment:2>

Django

unread,
Dec 31, 2022, 11:22:01 AM12/31/22
to django-...@googlegroups.com

Old description:

> 'root': {
> 'handlers': ['rotatingFile'],
> 'level': LOG_LEVEL,
> },
>
> },
> 'formatters': {
> 'verbose': {
> 'format': '{asctime} {levelname} {name} {module} {process:d}
> {thread:d} {message}',
> 'style': '{',
> },
> },
> }}}

New description:

I was trying to configure access logs using Django logging as per
documentation https://docs.djangoproject.com/en/4.1/howto/logging/
I wanted to collect all access logs from INFO. It works perfectly when in
development mode. However, when I switched to Gunnicron in production, I
got only warnings and higher status logs.

After a bit of searching, I have found this ticket below, which kind of
summarises this behaviour.
https://code.djangoproject.com/ticket/33897
I think the documentation should say that once in production with
Gunnicorn, there are no access logs with INFO status from the Django
logger.

My logging configuration in settings.py is as follow:


{{{

#LOGGING SETTINGS
LOG_MAX_SIZE = int(os.getenv("LOG_MAX_SIZE")) #max size of single log file
in bytes
LOG_NUMBER_OF_FILES = int(os.getenv("LOG_NUMBER_OF_FILES")) #number of old
log files
LOG_LOCATION = os.getenv("LOG_LOCATION") #default name and location of a
log file
LOG_LEVEL = os.getenv("LOG_LEVEL")

.env file has the following entries:


{{{
#LOGGING SETTINGS
LOG_MAX_SIZE = 52428800 #max size of single log file in bytes
LOG_NUMBER_OF_FILES = 5 #number of old log files
LOG_LOCATION = '/logs/rotatingLog.log' #default name and location of a log
file
LOG_LEVEL = 'INFO' #Log level to be collected through all django loggers -
options include: DEBUG, INFO, WARNING, ERROR, CRITICAL
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34236#comment:3>

Django

unread,
Jan 2, 2023, 12:28:53 AM1/2/23
to django-...@googlegroups.com
#34236: Django logging when in production with Gunnicron
-------------------------------+--------------------------------------
Reporter: Derek | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 4.1
Severity: Normal | Resolution: invalid

Keywords: logging | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Replying to [ticket:34236 Derek]:


> I was trying to configure access logs using Django logging as per
documentation https://docs.djangoproject.com/en/4.1/howto/logging/
> I wanted to collect all access logs from INFO. It works perfectly when
in development mode. However, when I switched to Gunnicron in production,
I got only warnings and higher status logs.

It's not strictly related with `Gunicorn`, and it's already
[https://docs.djangoproject.com/en/stable/ref/logging/#django-server
documented] that the `django.server` logger logs ''"messages related to
the handling of requests received by the server invoked by the
**runserver** command."''

--
Ticket URL: <https://code.djangoproject.com/ticket/34236#comment:4>

Reply all
Reply to author
Forward
0 new messages