spring_reference/IX. ‘How-to’ guides/66.2.1. Use YAML or JSON to...

4 lines
553 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 66.2.1. 使用YAML或JSON配置Log4j2
除了它的默认XML配置格式Log4j 2也支持YAML和JSON配置文件。想要使用其他配置文件格式来配置Log4j 2你需要添加合适的依赖到classpath。为了使用YAML你需要添加`com.fasterxml.jackson.dataformat:jackson-dataformat-yaml`依赖Log4j 2将查找名称为`log4j2.yaml`或`log4j2.yml`的配置文件。为了使用JSON你需要添加`com.fasterxml.jackson.core:jackson-databind`依赖Log4j 2将查找名称为`log4j2.json`或`log4j2.jsn`的配置文件