Created
May 4, 2020 09:01
-
-
Save EmadMokhtar/c24710aa216a9f201107eae06a7e4d19 to your computer and use it in GitHub Desktop.
Django Recipies
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
# Add this part to settings to get file logger in your Django app. | |
# Log files path on Production environment | |
LOGS_DIR = '/logs' | |
# Check if the directory exists and if not create it | |
if not os.path.exists(LOGS_DIR): | |
os.mkdir(LOGS_DIR) | |
# Handler | |
'app-file-log': { | |
'level': 'DEBUG', | |
'class': 'logging.handlers.RotatingFileHandler', | |
'filename': os.path.join(LOGS_DIR, 'rtb.log'), | |
'maxBytes': 1024 * 1024 * 15, # 15MB | |
'backupCount': 10 | |
}, | |
# Assign the handler to a logger | |
'logger_name': {'level': 'INFO', 'handlers': ['app-file-log']} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment