将 log4j2.properties 配置到 spring 启动时出现问题(使用 gradle)
Problem with configuring log4j2.properties into spring boot( using gradle)
我在 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
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 引导参考文档中查找所有信息:
我在 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
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 引导参考文档中查找所有信息: