This screams to me a code issue, yet after an hour of research I am still unsure as to why I can't see anything lower than a warning in the railway logs. The exact same branch, codebase, and env variables work fine, as I am able to see logs locally, but not on Railway. It was working a few months ago, but when I updated from django 3.2 to 4.0 and from heroku to nixpacks, the logging stopped showing up
#Django not request logging
53 messages · Page 1 of 1 (latest)
Project ID: 9b0e625c-b8d1-4c35-8629-60c32ab222ed
You might find these helpful:
⚠️ experimental feature
9b0e625c-b8d1-4c35-8629-60c32ab222ed
nixpacks.toml
[start]
cmd = 'python manage.py migrate && gunicorn --max-requests 1000 --workers 5 --threads 2 timeweb.wsgi'```
Django Logging config
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '{levelname} {asctime} {module} {process:d} {thread:d}>> {message}',
'style': '{',
},
'simple': {
'format': '{asctime} <<{levelname}>> {message}',
'style': '{',
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
}
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': False,
},
}
}```
make sure your environment variable is set properly in the project, you could also just hard code them to test it
hmmmmm
interesting
not the environment variables
but python 3.8 logs it
while python 3.10 doesn't
i guess that fixed my error but that is a bit odd
interesting
3.10 is a bit new iirc
3.9 is the recommended for prod last i checked
i can try redeploying with 3.9 just to single out which version is causing the issue
3.9 works
it does indeed seem to be 3.10
figures
hello,
I'm running into a similar problem from my original question for this thread. Info logging works but request logging on the other hand does not.
locally this works perfectly
but on railway it doesn't log requests
django's logger api works from views.py which means i can get my own log messages to work if I call it on a view function
which is pretty strange since my env variables are the same
as i mentioned in the original thread this worked on heroku way back ago but it just stopped working out of no where
Django not request logging
logging config (copied from django docs)
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '{levelname} {asctime} {module} {process:d} {thread:d}>> {message}',
'style': '{',
},
'simple': {
'format': '{asctime} <<{levelname}>> {message}',
'style': '{',
},
},
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
}
},
'loggers': {
'django': {
'handlers': ['console'],
'propagate': True,
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': False,
},
}
}```
this may be a shot in the dark but try setting PYTHONUNBUFFERED = 1 in the service variables
well I did say shot in the dark
true lol
are the info logs somehow going to a file and not stdout?
nope they've only been configured for stdout
hm
tomorrow i will experiment with https://pypi.org/project/django-request-logging/
to try to pinpoint which end of the issue it is at
maybe Django's logger doesn't respect the python unbuffered variable
i doubt it's a buffer issue
there are logs still showing up
manual calls to logger still show up in the logs
and tail appropriately
so info logs trigger by routes just aren't getting logged
but they do print on your computer?
yes
^
fishy
hello, any update on this?
interestingly enough, it works a few days later