Please find below my log4.xml configuration for rolling file appender
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="instrumentationAppender" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="C:\\Users\\Test\\Downloads\\Testlogs\\instrumentation.log"/>
<param name="Append" value="true" />
<param name="Encoding" value="UTF-8" />
<param name="MaxFileSize" value="100KB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] (%C:%L) - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="INFO" />
<param name="LevelMax" value="INFO" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="debugAppender" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="C:\\Users\\Test\\Downloads\\Testlogs\\Test.log"/>
<param name="Append" value="true" />
<param name="Encoding" value="UTF-8" />
<param name="MaxFileSize" value="100KB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] (%C:%L) - %m%n"/>
</layout>
<param name="ImmediateFlush" value="true" />
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="DEBUG" />
<param name="LevelMax" value="DEBUG" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="errorAppender" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="C:\\Users\\Test\\Downloads\\Testlogs\\Test.log"/>
<param name="Append" value="true" />
<param name="Encoding" value="UTF-8" />
<param name="MaxFileSize" value="100KB"/>
<param name="MaxBackupIndex" value="10"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] (%C:%L) - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="ERROR" />
<param name="LevelMax" value="FATAL" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<category name="com.practice.Test" additivity="false">
<priority value="DEBUG"/>
<appender-ref ref="instrumentationAppender" />
<appender-ref ref="debugAppender" />
<appender-ref ref="errorAppender" />
</category>
The issue is instrumentationAppender,debugAppender and errorAppender are refered by com.practice pakaage as defined in above category. In all the appenders maxFileSize is 100kb and configured for Test.log file. The issue Test.log file does not get rollover after 100kb of size. All logs just get appended to same Test.log file. How do configure RollingAppender based on size?
Thanks in advance for the help.