以下是我的项目结构:
src-〉main-〉java-〉com-〉dot-〉filter-〉这里有很多文件夹(ax,by,cz),它们包含了这些类
源代码-〉主要-〉java-〉资源-〉log4j2.properties
以下是我的log4j2.properties文件:
status = error
name = PropertiesConfig
property.filename = C:\\logs\\debug.log
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = debug
appenders = rolling
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = C:\\logs\\PreviousLogs\\-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
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 = 20
loggers = rolling
logger.rolling.name = com.dite.filter.ax
logger.rolling.level = debug
logger.rolling.additivity = true
logger.rolling.appenderRef.rolling.ref = RollingFile
对于上述配置,我无法生成日志
这一行logger.rolling.name = com.dite.filter.ax
有什么问题吗?
谁能告诉我在这个配置中我犯了什么错误?
或
建议我其他方法来为上述指定包结构生成日志
1条答案
按热度按时间cwdobuhd1#
您对
com.dite.filter.ax
记录器的配置是正确的,但您没有配置根记录器。如果要忽略所有不是来自
com.dite.filter.ax
及其后代的日志消息,请用途: