Module log4rs::file [] [src]

Support for log4rs configuration from files.

Multiple file formats are supported, each requiring a Cargo feature to be enabled. YAML support requires the yaml feature, JSON support requires the JSON feature, and TOML support requires the toml feature.

Syntax

All file formats currently share the same structure. The example below is of the YAML format, but JSON and TOML should follow.

# If set, log4rs will scan the file at the specified rate in seconds for
# changes and automatically reconfigure the logger.
refresh_rate: 30

# The "appenders" map contains the set of appenders, indexed by their names.
appenders:

  foo:

    # All appenders must specify a "kind", which will be used to look up the
    # logic to construct the appender in the `Builder` passed to the
    # deserialization function.
    kind: console

    # Filters attached to an appender are specified inside the "filters"
    # array.
    filters:

      -
        # Like appenders, filters are identified by their "kind".
        kind: threshold

        # The remainder of the configuration is passed along to the
        # filter's builder, and will vary based on the kind of filter.
        level: error

    # The remainder of the configuration is passed along to the appender's
    # builder, and will vary based on the kind of appender.
    # Appenders will commonly be associated with an encoder.
    encoder:

      # Like appenders, encoders are identified by their "kind". If no kind
      # is specified, it will default to "pattern".
      kind: pattern

      # The remainder of the configuration is passed along to the
      # encoder's builder, and will vary based on the kind of encoder.
      pattern: "{d} [{t}] {m}{n}"

# The root logger is configured by the "root" map. It is optional.
root:

  # The maximum log level for the root logger.
  level: warn

  # The list of appenders attached to the root logger. Defaults to an empty
  # list if not specified.
  appenders:
    - foo

# The "loggers" map contains the set of configured loggers, indexed by their
# names.
loggers:

  foo::bar::baz:

    # The maximum log level. Defaults to the level of the logger's parent if
    # not specified.
    level: trace

    # The list of appenders attached to the logger. Defaults to an empty
    # list if not specified.
    appenders:
      - foo

    # The additivity of the logger. If true, appenders attached to the
    # logger's parent will also be attached to this logger. Defauts to true
    # if not specified.
    additive: false

Modules

raw

Types used to deserialize config files.

Structs

Config

A deserialized log4rs configuration file.

Deserializers

A container of Deserializers.

Enums

Error

An error returned when deserializing a TOML configuration into a log4rs Config.

Format

Specifies the format of a configuration file.

Traits

Deserialize

A trait for objects that can deserialize log4rs components out of a config.