Skip to content

Instantly share code, notes, and snippets.

@Afeez1131
Created July 30, 2023 08:55
Show Gist options
  • Save Afeez1131/1d5608f286b527c1c844769130f646dd to your computer and use it in GitHub Desktop.
Save Afeez1131/1d5608f286b527c1c844769130f646dd to your computer and use it in GitHub Desktop.
LOG_DIR = os.path.join(BASE_DIR, 'logs') # the log dir
os.makedirs(LOG_DIR, exist_ok=True) # check to see if we have the directory, if not, create it.
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"simple": {
"format": "%(levelname)s %(asctime)s %(message)s"
},
"detailed": {
"format": "%(levelname)s %(asctime)s %(module)s %(message)s"
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"level": "INFO",
"formatter": "simple"
},
"file": {
"class": "logging.FileHandler",
"level": "INFO",
"filename": os.path.join(LOG_DIR, 'logging.log'),
"formatter": "detailed",
},
},
"loggers": {
"django": {
"handlers": ["file"],
"level": "DEBUG",
},
"account": {
"handlers": ["console", "file"],
"level": "INFO",
},
"core": {
"handlers": ["console", "file"],
"level": "INFO"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment