What is a sample default config file in YAML for log4j2?

北城以北 提交于 2019-12-02 20:22:04

The YAML file

The equivalent YAML file ( log4j2.yaml ) looks like this:

Configuration:
  status: warn

  Appenders:
    Console:
      name: Console
      target: SYSTEM_OUT
      PatternLayout:
        Pattern: "%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"

  Loggers:
    Root:
      level: error
      AppenderRef:
        ref: Console

This file is automatically loaded (assuming that the file is in the classpath and having the required dependencies), as described in Automatic Configuration.

Maven

If you are using Maven, the following dependencies are required:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.1</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.1</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-yaml</artifactId>
    <version>2.5.0</version>
</dependency>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!