Changed to rotating log file handler.

Added logging description in settings.py
Updated .gitignore to ignore rotated log files.

Logging adapted from http://stackoverflow.com/questions/14354066/django-log-rotating-and-log-file-ownership
This commit is contained in:
Adarnof 2016-01-02 22:34:44 +00:00
parent 5f70e68cc2
commit 583be5a72e
2 changed files with 33 additions and 18 deletions

2
.gitignore vendored
View File

@ -45,7 +45,7 @@ coverage.xml
*.pot *.pot
# Django stuff: # Django stuff:
*.log *.log*
# Sphinx documentation # Sphinx documentation
docs/_build/ docs/_build/

View File

@ -348,6 +348,19 @@ DISCORD_SERVER_ID = os.environ.get('AA_DISCORD_SERVER_ID', '')
DISCORD_USER_EMAIL = os.environ.get('AA_DISCORD_USER_EMAIL', '') DISCORD_USER_EMAIL = os.environ.get('AA_DISCORD_USER_EMAIL', '')
DISCORD_USER_PASSWORD = os.environ.get('AA_DISCORD_USER_PASSWORD', '') DISCORD_USER_PASSWORD = os.environ.get('AA_DISCORD_USER_PASSWORD', '')
#####################################
# Logging Configuration
#####################################
# Set log_file and console level to desired state:
# DEBUG - basically stack trace, explains every step
# INFO - model creation, deletion, updates, etc
# WARN - unexpected function outcomes that do not impact user
# ERROR - unexcpeted function outcomes which prevent user from achieving desired outcome
# EXCEPTION - something critical went wrong, unhandled
#####################################
# Recommended level for log_file is INFO, console is DEBUG
# Change log level of individual apps below to narrow your debugging
#####################################
LOGGING = { LOGGING = {
'version': 1, 'version': 1,
'disable_existing_loggers': False, 'disable_existing_loggers': False,
@ -361,61 +374,63 @@ LOGGING = {
}, },
}, },
'handlers': { 'handlers': {
'debug_file': { 'log_file': {
'level': 'INFO', 'level': 'INFO', # edit this line to change logging level to file
'class': 'logging.FileHandler', 'class': 'logging.handlers.RotatingFileHandler',
'filename': 'debug.log', 'filename': os.path.join(BASE_DIR,'allianceauth.log'),
'formatter': 'verbose' 'formatter': 'verbose',
'maxBytes': 1024*1024*5, # edit this line to change max log file size
'backupCount': 5, # edit this line to change number of log backups
}, },
'console': { 'console': {
'level': 'DEBUG', 'level': 'DEBUG', # edit this line to change logging level to console
'class': 'logging.StreamHandler', 'class': 'logging.StreamHandler',
'formatter': 'verbose', 'formatter': 'verbose',
} }
}, },
'loggers': { 'loggers': {
'authentication': { 'authentication': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'celerytask': { 'celerytask': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'eveonline': { 'eveonline': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'groupmanagement': { 'groupmanagement': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'hrapplications': { 'hrapplications': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'portal': { 'portal': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'registration': { 'registration': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'services': { 'services': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'srp': { 'srp': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'timerboard': { 'timerboard': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
'util': { 'util': {
'handlers': ['debug_file', 'console'], 'handlers': ['log_file', 'console'],
'level': 'DEBUG', 'level': 'DEBUG',
}, },
} }