How to configure the log4j TimeBasedRollingPolicy on EAP 4.x
Issue
I want to use TimeBasedRollingPolicy so that the logfiles will rotate for example every hou,r and then the logfile should be compressed automatically.
I have put the apache-log4j-extras-1.0.jar in the lib directory of my jboss application server, in addition to the log4j.jar file, so that the TimeBasedRollingPolicy.class file would be found, but I get the error message:
Element type "rollingPolicy" must be declared
My configuration looks as follows:
<appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${Log.Home}/${Instance}-${jboss.bind.address}-console.log"/>
<param name="Append" value="false"/>
<param name="DatePattern" value="yyyy-MM-dd-HH"/>
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="${Log.Home}/${Instance}-${jboss.bind.address}-console.%d.log.gz" />
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d LOGINFO: %m%n"/>
</layout>
</appender>
Environment
JBoss Enterprise Application Platform(EAP) 4.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.