Skip to content Skip to sidebar Skip to footer

Django: Setup An Efficient Logging System For A Website In Production

Alright so the development phase is over and now my website is live in prod. However, I have not set up the logging. My website is located in /var/www/html dir. Ideally I would lik

Solution 1:

  1. No its not standard. Add the following statements to settings.py and modify the log file path to your needs:

     LOGGING = {
         'version': 1,
         'disable_existing_loggers': False,
         'handlers': {
             'file': {
                 'level': 'DEBUG',
                 'class': 'logging.FileHandler',
                 'filename': '/path/to/django/debug.log',
             },
         },
         'loggers': {
             'django': {
                 'handlers': ['file'],
                 'level': 'DEBUG',
                 'propagate': True,
             },
         },
     }
    
  2. Refer this for setting up suitable permissions for log files: Permission Denied when writing log file

  3. You will have to use logrotate otherwise make use of kafka server to maintain logs.

Post a Comment for "Django: Setup An Efficient Logging System For A Website In Production"