Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!