tags:

views:

282

answers:

2

Hi,

My jboss application server log file named jboss-log4j.xml has the following configuration for the rolling file appender

<appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
 <param name="File" value="${jboss.server.log.dir}/server.log"/>
 <param name="Append" value="false"/>
 <param name="MaxFileSize" value="500KB"/>
 <param name="MaxBackupIndex" value="1"/>

 <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
 </layout>      
</appender>

What does this exactly do ? How should I set it to do either of the two things ? 1. Delete logs older than 5 days or 2. Delete logs when they exceed 800MB, so that once they are deleted the new logs can take effect

A: 

Have a look HERE.

thelost
+1  A: 

Most of the parameters are explained in the manual I linked to your earlier question here. Even if that shows the parameters in a property file, the name and semantics of the parameters is the same.

AFAIK you can't easily make a log file roll over every 5 days. The closest to this is weekly rollover. For this you should use a DailyRollingFileAppender as I showed in my previous answer, and set its date pattern to

<param name="DatePattern" value="'.'yyyy-ww"/>

See the usage options of DailyRollingFileAppender here.

Setting the size limit of the RollingFileAppender shown in your post to 800MB instead of 500KB is a task I am sure you can resolve yourself ;-)

So you can easily have a log file rolling over either at the start of every week or upon reaching a specified size limit. However, I have a vague recollection that the two don't go together. You either have a DailyRollingFileAppender or a RollingFileAppender - Log4J doesn't provide an appender with both functionality at the same time. Neither to roll over your log file every 5 days - your only option to achieve this is to implement your own custom appender.

Péter Török