我正在尝试在我的应用程序中使用Log4j2
,我的相关配置如下所示:
*.*.log4j2.appender.file.type = RollingRandomAccessFile;
*.*.log4j2.appender.file.name = file;
*.*.log4j2.appender.file.fileName = "$ROOT/var/output/logs/$APP";
*.*.log4j2.appender.file.filePattern = "$ROOT/var/output/logs/$APP.%d{yyyy-MM-dd-HH}";
*.*.log4j2.appender.file.layout.type = PatternLayout;
*.*.log4j2.appender.file.layout.pattern = "%d{DATE} [%p] %X{requestId} (%t) %c: %m%n";
但是,当我运行我的程序时,我得到了这个错误:
955 main ERROR RollingRandomAccessFile contains an invalid element or attribute "fileName"
有人可以帮我解决这个问题吗? 非常感谢您的帮助 最诚挚的问候。
答案 0 :(得分:1)
我怀疑*.*.log4j2
前缀可能是相关的。你可以尝试没有这个,比如example in the log4j2 manual吗?
appender.rolling.type = RollingRandomAccessFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = target/rolling2/test1-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d %p %C{1.} [%t] %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 2
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 5
rootLogger.level = info
rootLogger.appenderRef.rolling.ref = RollingFile