If I start application using uwsgi I don't see logs related to django.requests.
But If I start the same code on the same machine using
manage.py runserver 8080
it works perfectly.
Any ideas why it might happen?
I run uwsgi by this command
/home/gs/python-env/bin/uwsgi --ini /etc/uwsgi.d/uwsgi.ini --static-map /static=/home/gs/api/static/
uwsgi.ini
[uwsgi] http-socket=:8080 home=/home/gs/python-env chdir=/home/gs/api module=server.wsgi env=server.settings processes=1 enable-threads=true
My logging configuration from settings.py
LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(process)d %(threadName)s %(module)s %(funcName)s %(message)s' } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', }, 'file': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'filename': '/var/log/gs/api.log', 'formatter': 'verbose', 'maxBytes': 1024 * 1024 * 16, # 16Mb }, 'elasticsearch': { 'level': 'DEBUG', 'class': 'api.common.elasticsearch_log_handler.ElasticSearchHandler', 'hosts': [{'host': cluster.ES_HOST, 'port': 443}], 'es_index_name': 'logstash', 'es_additional_fields': {'type': 'api', 'cluser': cluster.CLUSTER_NAME}, 'auth_type': ElasticSearchHandler.AuthType.NO_AUTH, 'use_ssl': True, } }, 'loggers': { 'django': { 'handlers': ['file', 'elasticsearch', 'console'], 'level': 'INFO', 'propagate': True }, 'django.request': { 'handlers': ['file', 'elasticsearch', 'console'], 'level': 'DEBUG', 'propagate':False } } }
If I change info to debug for 'django' I will see my logs from django logger but not from django.request.
UPD: If I write my own middleware I can log requests. But I want to know why django.request doesn't work with uwsgi.
1 Answers
Answers 1
Django's runserver
provides the log messages that show up under django.server
. When not running under runserver
there are still some messages that can be logged to django.request
(mostly error messages) but the informational log message for each request only exists in runserver
. I verified this by looking at the uWSGI and the Django source.
If you want a similar log message you can use django-request-logging.
0 comments:
Post a Comment