gpt4 book ai didi

spring - 为多个包配置 RollingFileAppenders Log4j2 .properties/.yaml,没有 .xml

转载 作者:行者123 更新时间:2023-12-01 23:30:10 26 4
gpt4 key购买 nike

这是我的 .properties 文件,

property.filename = logs/app.log
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = "%-5p %c{1} - %m%n
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = logs/app-%d{MM-dd-yy}-%i.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%-5level] %d{DATE} %-5p [%t] %c{1} - %msg%n
appender.rolling.append = true
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 10MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 5
logger.rolling.name = org.springframework.boot
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = RollingFile
logger.rolling.name = com.org.abc.package
logger.rolling.level = debug
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = RollingFile
rootLogger.level = fatal
rootLogger.appenderRef.stdout.ref = STDOUT

问题是我试图为两个包显式设置日志记录。但是,此配置不适用于这两个包。如何使用 log4j2 属性或 yaml 文件为多个包配置日志记录。

最佳答案

loggers = springframework,application

logger.springframework.name = org.springframework.boot
logger.springframework.level = info
logger.springframework.appenderRefs = RollingFile
logger.springframework.additivity = true
logger.springframework.appenderRef.rolling.ref = RollingFile

logger.application.name = com.abc.package
logger.application.level = debug
logger.application.appenderRefs = RollingFile
logger.application.additivity = false
logger.application.appenderRef.rolling.ref = RollingFile

关于spring - 为多个包配置 RollingFileAppenders Log4j2 .properties/.yaml,没有 .xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39262436/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com