Setting up rollover strategies in log4j2.properties

Can someone help me with setting up rollover strategy in log4j2.properties? I set it as -

#Appender appender.test.type=RollingFile appender.test.name=test appender.test.fileName=${logPath}/test.log appender.test.filePattern = ${logPath}/test-%i.log appender.test.layout.type=PatternLayout appender.test.layout.pattern=%d{ISO8601} %-5p [%t] %m%n appender.test.policies.type=Policies appender.test.policies.size.type=SizeBasedTriggeringPolicy appender.test.policies.size.size=1MB appender.test.strategies.type=Strategies appender.test.strategies.rollover.type=DefaultRolloverStrategy appender.test.strategies.rollover.max=5 

I wrote this tutorial https://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax

I did not find anything to implement the rollover strategy, and what you see above is what I thought would work. But, unfortunately, and obviously this is not so.

Here is the error:

 2015-11-09 13:30:42,175 localhost-startStop-1 ERROR Unable to locate plugin for Strategies 
+5
source share
1 answer

Another section may be useful on this page:

http://logging.apache.org/log4j/2.x/manual/configuration.html#Properties

It contains an example configuration of rollover properties. In addition, you can find the supported RollingFileAppender options on the manual page: http://logging.apache.org/log4j/2.x/manual/appenders.html#RollingFileAppender

Try the following:

 appender.test.strategy.type=DefaultRolloverStrategy appender.test.strategy.max=5 

Let me know if it works and I will add it to the manual page.

+5
source

Source: https://habr.com/ru/post/1235549/


All Articles