0
我使用log4j2在我的应用程序无条件删除不支持的,发现我收到以下错误:Log4j2 - 缺少删除条件:
Missing Delete conditions: unconditional Delete not supported
2017-02-16 12:21:25,286 http-nio-8080-exec-7 ERROR Error processing element And ([Delete: null]): CLASS_NOT_FOUND
2017-02-16 12:21:25,347 http-nio-8080-exec-7 ERROR Missing Delete conditions: unconditional Delete not supported
2017-02-16 12:21:25,347 http-nio-8080-exec-7 ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.rolling.action.DeleteAction for element Delete. java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
这是我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Properties>
<Property name="basePath">C:\\logs</Property>
</Properties>
<Appenders>
<RollingFile name="fileLogger" fileName="${basePath}/kiosk.log" filePattern="${basePath}/kiosk -%d{yyyy-MM-dd}.log">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
</Policies>
<DefaultRolloverStrategy stopCustomActionsOnError="true">
<!-- custom action executed asynchronously after the rollover -->
<Delete basePath="${basePath}" maxDepth="2" followLinks="false">
<And>
<IfFileName path="*/kiosk-*.log." /> <!-- delete only files matching this pattern -->
<IfLastModified duration="7d" /> <!-- delete if 7 days or older -->
</And>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="uk.co.kiosk.logging" level="debug" additivity="true">
<appender-ref ref="fileLogger" level="debug" />
</Logger>
<Root level="debug" additivity="false">
<appender-ref ref="console" />
</Root>
</Loggers>
</Configuration>
我也有注意到文件在7天后没有被删除。 这是我的Maven项:
dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
有什么我做错了,可以在任何一个提醒?他们正在创建一个好的文件,但不会删除,然后很明显,然后在控制台中得到这个错误。 如果还有其他东西我可以上传,这将有所帮助,高兴地这样做。