Opinionated logging configuration using microcosm wiring.
from microcosm.api import create_object_graph
graph = create_object_graph(name="foo")
graph.use("logger")
- Logging should "just work" without large amounts of configuration
- Outside of development and unittesting, log aggregation should be automatic (e.g. to loggly)
- INFO level logging should be the default behavior; third-party libraries that mistakenly spew output at INFO should be turned down by default
To set the global logging level to something other than info, use:
config.logging.level = "WARN"
To set the console logger format to json:
config.logging.stream_handler.formatter = "JSONFormatter"
To enable loggly, set its token
and configure an environment
name:
config.logging.loggly.token = "LOGGLY_TOKEN"
config.logging.loggly.environment = "ENVIRONMENT_NAME"
To disable loggly unconditionally:
config.logging.loggly.enabled = False
To tune the logging levels of third-party components:
config.logging.loggly.levels.override.warn = ["foo", "bar"]
To enable logstash to work with a local client, enable it explicitly:
config.logging.logstash.enabled = True