Module log4rs_routing_appender::route::pattern [] [src]

A router which constructs appenders from a template configuration.

Strings in the configuration template may contain substitution directives. The format is similar to that of the log4rs pattern encoder, except that it is prefixed with a $ to avoid conflicts with patterns in the templated configuration itself. Format specifications are not supported.

Only one formatter is currently supported:

  • mdc - An entry from the MDC. The first argument is required, and specifies the key to look up. If the key is not present, an error is raised. A second, optional argument allows a replacement string to be used if the key is not present.

Examples

Assume the MDC looks like {user_id: sfackler}.

kind: file
path: "logs/${mdc(user_id)}/${mdc(job_id)}.log"

will fail to parse, since there is no MDC entry for job_id. If we add a default value, like

kind: file
path: "logs/${mdc(user_id)}/${mdc(job_id)(no_job)}.log"

it will then parse to

kind: file
path: "logs/sfackler/no_job.log"

Structs

PatternRouter

A router which expands an appender configuration template.

PatternRouterConfig

Configuration for the PatternRouter.

PatternRouterDeserializer

A deserializer for the PatternRouter.