Skip to content

Instantly share code, notes, and snippets.

@chenjianjx
Forked from jarvys/loggers.py
Created March 8, 2016 09:55
Show Gist options
  • Save chenjianjx/29c08384ccae836777dd to your computer and use it in GitHub Desktop.
Save chenjianjx/29c08384ccae836777dd to your computer and use it in GitHub Desktop.
logging configuration for django
import os
LOGS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'logs')
LOGGING = {
'version': 1,
'dusable_existing_loggers': True,
'formatters': {
'normal': {
'format': '%(levelname)s %(asctime)s %(module)s %(message)s'
},
'simple': {
'format': '%(levelname)s %(module)s %(message)s'
}
},
'handlers': {
'django': {
'level': 'DEBUG',
'class': 'logging.handlers.TimedRotatingFileHandler',
'when': 'D',
'interval': 1,
'backupCount': 5,
'filename': os.path.join(LOGS_DIR, 'django.log'),
'formatter': 'normal'
},
'app': {
'level': 'DEBUG',
'class': 'logging.handlers.TimedRotatingFileHandler',
'when': 'D',
'interval': 1,
'backupCount': 5,
'filename': os.path.join(LOGS_DIR, 'app.log'),
'formatter': 'normal'
}
},
'loggers': {
'django': {
'handlers': ['django'],
'propagate': False,
'level': 'DEBUG'
},
'': {
'handlers': ['app'],
'level': 'DEBUG'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment