Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

277
Vistas
Django Logging not outputting to log file on nginx server

My Django Logger works fine on my local machine but does not work when I deploy it to the server.

Local: OS X 10.9.5, Python 2.7, Django 1.10.5

AWS Server: Ubuntu, Nginx, Gunicorn, Django

On my local setup I run python manage.py runserver, this creates the debug.log file in my root directory. I access the site through localhost:8000 when I boot up the local server via virtual environment and I get these logs on my debug.log.

"GET / HTTP/1.1" 200 2908
"GET /projects HTTP/1.1" 200 3461
Inside app views index

On my production server I run python manage.py runserver, this creates the debug.log file. I restart Nginx server by sudo service nginx restart, and I access my webpage and click on the same links as when I was running the local server.

When I vim debug.log into the debug.log file, I can not see any of my debug messages after I visit the website and click on the same links in the webpage.

Why is there no logging data being recorded into debug.log on my production environment? What am I missing?

views.py

import logging
logger = logging.getLogger(__name__)

def index(request):
    logger.debug('Inside app views index')
    return render(request, "first_app/index.html")

local_settings.py (It shouldn't matter, but I am using local_settings.py in my local machine and production server)

#BASE_DIR was already part of django settings.py file when created.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'file': {
            'level': 'DEBUG',
            'class': 'logging.FileHandler',
            'filename': os.path.join(BASE_DIR, 'debug.log'),
        },
        'null': {
            'class': 'logging.NullHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'apps': {
            'handlers': ['file'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'django.db.backends': {
            'handlers': ['null'],
            'propagate': False,
        },
    },
}

My file routes are

-homepage
  -apps
  -homepage
  -static
  -venv
  manage.py
  homepage.sock
  db.sqlite3
  debug.log
  requirement.txt
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I believe that the requests (GET, POST, etc) logs are intercepted by Nginx and logged to its nginx-access.log, while your INFO, ERROR logs should be in debug.log

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda