Skip to content

Instantly share code, notes, and snippets.

@garudareiga
Created January 15, 2014 21:53
Show Gist options
  • Save garudareiga/8445508 to your computer and use it in GitHub Desktop.
Save garudareiga/8445508 to your computer and use it in GitHub Desktop.
A Python logging configuration file with JSON format
{
"version": 1,
"disable_existing_loggers": false,
"formatters": {
"simple": {
"format": "%(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.RotatingFileHandler",
"level": "INFO",
"formatter": "simple",
"filename": "info.log",
"maxBytes": "10485760",
"backupCount": "20",
"encoding": "utf8"
},
"error_file_handler": {
"class": "logging.handlers.RotatingFileHandler",
"level": "ERROR",
"formatter": "simple",
"filename": "errors.log",
"maxBytes": "10485760",
"backupCount": "20",
"encoding": "utf8"
}
},
"loggers": {
"logger2": {
"level": "DEBUG",
"handlers": ["console", "info_file_handler", "error_file_handler"],
"propagate": "no"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment