Skip to content

Instantly share code, notes, and snippets.

@OrangeTux
Created November 13, 2013 14:52
Show Gist options
  • Save OrangeTux/7450331 to your computer and use it in GitHub Desktop.
Save OrangeTux/7450331 to your computer and use it in GitHub Desktop.
Sample config for Python's logging module. Load it with ` logging.config.dictConfig(yaml.load(open('path/to/config','r')))`.
version: 1
formatters:
simple:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
console:
class: logging.StreamHandler
formatter: simple
level: DEBUG
stream: ext://sys.stdout
file_debug:
class: logging.handlers.RotatingFileHandler
formatter: simple
level: DEBUG
filename: /path/to/debug.log
maxBytes: 10485760
backupCount: 3
file_info:
class: logging.handlers.RotatingFileHandler
formatter: simple
level: INFO
filename: /path/to/info.log
maxBytes: 10485760
backupCount: 3
file_error:
class: logging.handlers.RotatingFileHandler
formatter: simple
level: ERROR
filename: /path/to/error.log
maxBytes: 10485760
backupCount: 3
root:
level: DEBUG
handlers: [console, file_info, file_error, file_debug]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment