我在scr / main / resources中添加了一个log4j2.properties文件,但没有受到影响。不应自行检测log4j2.properties。如何检查是否未被检测到?
Log4j2.properties文件
status = error
name = PropertiesConfig
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = debug
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
答案 0 :(得分:2)
Spring Boot使用Logback作为日志框架。
如果要使用Log4j2,则必须进行一些配置。
排除默认记录器并添加log4j2入门依赖项:
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-log4j2'
}
configurations {
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
据我所知,Log4j2是使用XML文件而非属性文件配置的。
请在官方的Spring Boot参考文档中找到所有信息: