我正在使用带有sprint-boot 1.5的log4j2版本2.7:
我的配置文件(log4j2.xml)是:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="60">
<Properties>
<Property name="LOG_PATH">./log</Property>
<Property name="FILE_LOG_PATTERN">%date{yyyy-MM-dd'T'HH:mm:ss.SSSZ}{UTC}}, %5p, %X{component:-SERVICE}, %X{event:-EVENT}, ${PID:-???}, [%t], %40.40logger{40}, FCID=%X{FCID:-N/A}, %msg%n</Property>
<Property name="MAX_HISTORY">7</Property>
<Property name="MAX_FILE_SIZE">100MB</Property>
</Properties>
<Appenders>
<RollingFile name="FILE"
fileName="${LOG_PATH}/tests.log"
filePattern="${LOG_PATH}/tests.%d{yyyy-MM-dd}.%i.log.gz">
<PatternLayout>
<Pattern>${FILE_LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy/>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="${MAX_FILE_SIZE}"/>
</Policies>
<DefaultRolloverStrategy max="${MAX_HISTORY}"/>
</RollingFile>
</Appenders>
<Loggers>
<logger name="org.springframework" level="INFO"/>
<logger name="org.springframework.security.oauth2" level="INFO"/>
<logger name="org.springframework.http" level="ERROR"/>
<Logger name="org.springframework.boot" level="info"/>
<Logger name="org.springframework.boot.context.embedded.jetty" level="info"/>
<Root level="error">
<AppenderRef ref="FILE"/>
</Root>
</Loggers>
当我启动应用程序时出现此错误:
ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile. java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender
如果我删除了此错误未显示的其中一个政策。有什么问题?