[][src]Module log4rs::file

Support for log4rs configuration from files.

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

Syntax

All file formats currently share the same structure. The example below is of the YAML format.

# If set, log4rs will scan the file at the specified rate for changes and
# automatically reconfigure the logger. The input string is parsed by the
# humantime crate.
refresh_rate: 30 seconds

# 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 `Deserializers` 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".
      #
      # Default: 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.
root:

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

  # The list of appenders attached to the root logger.
  #
  # Default: empty list
  appenders:
    - foo

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

  foo::bar::baz:

    # The maximum log level.
    #
    # Default: parent logger's level
    level: trace

    # The list of appenders attached to the logger.
    #
    # Default: empty list
    appenders:
      - foo

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

Structs

Deserializers

A container of Deserializers.

Error

An error deserializing a configuration into a log4rs Config.

RawConfig

A raw deserializable log4rs configuration.

Traits

Deserializable

A trait implemented by traits which are deserializable.

Deserialize

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