Created
January 23, 2014 10:37
-
-
Save dmy3k/8576421 to your computer and use it in GitHub Desktop.
Part of django settings.py as a sample logging setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
p = lambda *x: os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', *x)) | |
# Main configuration goes here | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': True, | |
'formatters': { | |
'standard': { | |
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", | |
'datefmt' : "%d/%b/%Y %H:%M:%S" | |
}, | |
}, | |
'handlers': { | |
'null': { | |
'level':'DEBUG', | |
'class':'django.utils.log.NullHandler', | |
}, | |
'logfile': { | |
'level':'DEBUG', | |
'class':'logging.handlers.RotatingFileHandler', | |
'filename': p('../logs/app.log'), | |
'maxBytes': 1024 * 1024 * 5, | |
'backupCount': 3, | |
'formatter': 'standard', | |
}, | |
'console':{ | |
'level':'INFO', | |
'class':'logging.StreamHandler', | |
'formatter': 'standard' | |
}, | |
}, | |
'loggers': { | |
'django': { | |
'handlers':['console'], | |
'propagate': True, | |
'level':'WARN', | |
}, | |
'django.db.backends': { | |
'handlers': ['console'], | |
'level': 'DEBUG', | |
'propagate': False, | |
}, | |
'': { | |
'handlers': ['logfile'], | |
'level': 'DEBUG' if DEBUG else 'ERROR', | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment