Skip to content

Instantly share code, notes, and snippets.

@tachyondecay
Created January 7, 2016 23:54
Show Gist options
  • Save tachyondecay/bf1f283468a724b88f30 to your computer and use it in GitHub Desktop.
Save tachyondecay/bf1f283468a724b88f30 to your computer and use it in GitHub Desktop.
Logging for Flask app
logging_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"simple": {
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
}
},
"handlers": {
"console": {
"class": 'logging.StreamHandler',
"level": "DEBUG",
"formatter": "simple",
"stream": "ext://sys.stdout"
},
"info_file_handler": {
"class": 'logging.handlers.TimedRotatingFileHandler',
"level": "INFO",
"formatter": "simple",
"filename": "info.log",
"when": "D",
"interval": 7,
"backupCount": 6,
"encoding": "utf8"
},
"error_file_handler": {
"class": 'logging.handlers.TimedRotatingFileHandler',
"level": "ERROR",
"formatter": "simple",
"filename": "errors.log",
"when": "D",
"interval": 7,
"backupCount": 6,
"encoding": "utf8"
}
},
"root": {
"level": "INFO",
"handlers": ["console", "info_file_handler", "error_file_handler"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment