0
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
            'style': '{',
        },
        'simple': {
            'format': '{levelname} {message}',
            'style': '{',
        },
    },
    'handlers': {
        'server_logger': {
            'level': 'DEBUG',
            'class':'logging.handlers.RotatingFileHandler',
            'maxBytes': 1024*1024*100,
            'backupCount': 20,
            'filename': os.path.join(BASE_DIR, 'server.log'),
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['server_logger'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}

What is wrong with the above configuration and why don't I see my logs? Any thoughts?

sakthisundar
  • 3,278
  • 3
  • 16
  • 29
  • 1
    1. Print out BASE_DIR and make sure it's what you expect. It should preferably be an absolute path. 2. Does anything change if you change `'django'` to `''` under `'loggers'`? – Alex Hall Feb 22 '19 at 09:05
  • Alex, the second suggestion has worked. Do you want to comment, I will accept the answer? Also, could you explain why? 'django' means only for modules that start with 'django' and '' means for everything? – sakthisundar Feb 22 '19 at 09:08
  • That's roughly it. Do you want this logger to capture everything, or were you hoping to get only django logs? – Alex Hall Feb 22 '19 at 09:10
  • I wanted it to capture everything. Thanks, Alex. – sakthisundar Feb 22 '19 at 09:13

1 Answers1

1

Use the empty string '' as the key under 'loggers' to mark that as the root logger and capture messages from all loggers.

Alex Hall
  • 34,833
  • 5
  • 57
  • 89