I have an application setup on Elastic Beanstalk (with an auto-scaling load balancer) using Django. The configuration also uses apache httpd and mod_wsgi.
The app functions correctly but I am seeing an occasional error that for the life of me I cannot debug. This is due to the error itself not appearing in the error_log at any point.
A sample from the access log, (IP addresses omitted):
[15/Apr/2020:01:13:21 +0000] "GET /reroute/agument/ HTTP/1.1" 500 27 "-" ""
[15/Apr/2020:01:13:22 +0000] "GET /reroute/argument/ HTTP/1.1" 302 - "https://www.bing.com/" "Mozilla/5.0 (Linux; Android 4.4.3; KFSOWI) AppleWebKit/537.36 (KHTML, like Gecko) Silk/80.5.3 like Chrome/80.0.3987.162 Safari/537.36"
The top request shows an error request, the bottom a typical request. The main thing I notice here is the absence of a user-agent in the 500 request. Combing through the access_log, every single request of this type is missing the user-agent. I have no specific functionality setup to deter bots/spiders or the like.
These 500 errors happen randomly and have been doing so for the last few months. There have been no reports of these occurring with the end user, which leads me to believe two possibilities:
I really want to identify and stop these erroneous requests as it is affecting error reporting for the app itself. What would be the best way to identify the issue here?
The only functionality I have added to my beanstalk environment (through .ebextensions) is:
OK, so I'm dumb.
The reasons why these error messages were not appearing in my logs was simply a case of them not having a means to be displayed in the logs.
Setting up a simple logging dictionary in Django settings.py suddenly started displaying the stack traces of the 500 errors when they happened. From there, I could see it was a simple unhandled exception:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
},
"loggers": {
"django": {"handlers": ["console"], "level": "INFO"},
},
}