Last active
May 27, 2023 12:48
-
-
Save aybruhm/81d193ef23a01ed6c9682c33c8a84901 to your computer and use it in GitHub Desktop.
This code snippet is a configuration if you wish to log your Django application.
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 | |
from pathlib import Path | |
# Build paths inside the project like this: BASE_DIR / 'subdir'. | |
BASE_DIR = Path(__file__).resolve().parent.parent | |
# Logging configuration | |
LOGGING = { | |
"version": 1, | |
"disable_existing_loggers": False, | |
"handlers": { | |
"file": { | |
"level": "WARNING", | |
"class": "logging.FileHandler", | |
"filename": os.path.join(BASE_DIR, "filename.log"), | |
"formatter": "standard", | |
}, | |
}, | |
"formatters": { | |
"standard": { | |
"format": "%(asctime)s [%(levelname)s] - %(message)s", | |
}, | |
}, | |
"loggers": { | |
"django": { | |
"handlers": ["file"], | |
"level": "WARNING", | |
"propagate": True, | |
}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment