unilog.config

Small veneer on top of logback. Originally based on the logging initialization in riemann. Now diverged quite a bit.

For configuration, a single public function is exposed: start-logging! which takes care of configuring logback, later logging is done through standard facilities, such as clojure.tools.logging.

Two extension mechanism are provided to add support for more appenders and encoders, see build-appender and build-encoder respectively

appender-config

multimethod

Called by walking through each key/val pair in the main configuration map. This allows for early transformation of quick access keys such as: :console, :file, and :files

build-appender

multimethod

Given a prepared configuration map, associate a prepared appender to the :appender key.

build-encoder

multimethod

Given a prepared configuration map, associate a prepared encoder to the :encoder key.

build-rolling-policy

multimethod

Given a configuration map, build a RollingPolicy instance.

build-triggering-policy

multimethod

Given a configuration map, build a TriggeringPolicy instance.

default-configuration

A simple default logging configuration

default-encoder

Default encoder and pattern configuration

default-pattern

Default pattern for PatternLayoutEncoder

levels

Logging level names to logback level association

start-appender!

multimethod

Start an appender according to appender type

start-logging!

(start-logging! raw-config)(start-logging!)

Initialize logback logging from a map.

The map accepts the following keys as keywords - :level: Default level at which to log. - :pattern: The pattern to use for logging text messages - :console: Append messages to the console using a simple pattern layout. If value is a boolean, treat it as such and use a default encoder. If value is a string, treat it as a pattern and use a pattern encoder. If value is a map, expect encoder configuration in the map. - :file: A file to log to. May either be a string, the log file, or a map which accepts optional encoder configuration. - :files: A list of either strings or maps. strings will create text files, maps are expected to contain a :path key as well as an optional :json which when present and true will switch the layout to a JSONEventLayout for the logger. - :overrides: A map of namespace or class-name to log level, this will supersede the global level. - :external: Do not proceed with configuration, this is useful when logging configuration is provided in a different manner (by supplying your own logback config file for instance).

When called with no arguments, assume an empty map

example:

{:console   true
 :level     "info"
 :files     ["/var/log/app.log"
             {:file "/var/log/app-json.log"
              :encoder json}]
 :overrides {"some.namespace" "debug"}}