Log4j is not generating log backup

2

I have two jar in the same classpath, so they are using the same log4j.xml. The project in which xml is, does the roll correctly, but the other project does not.

I have set up the xml to generate 10 backup of size 1096K, but the backups are not being generated, and the main log file is deleted when it reaches the size limit.

log4j.xml:

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%c.%M()]: %m %n"></param>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMin" value="DEBUG" />
        <param name="LevelMax" value="FATAL" />
    </filter>
</appender>

<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="logs/arqGUI.log" />
    <param name="MaxFileSize" value="4096KB" />
    <param name="MaxBackupIndex" value="10" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%c.%M()]: %m %n"></param>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMin" value="DEBUG" />
        <param name="LevelMax" value="FATAL" />
    </filter>
</appender>

<appender name="FILE_SERVICE" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="logs/arqService.log" />
    <param name="MaxFileSize" value="1096KB" />
    <param name="MaxBackupIndex" value="10" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="[%d{ISO8601}][%-5p][%c.%M()]: %m %n"></param>
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMin" value="DEBUG" />
        <param name="LevelMax" value="FATAL" />
    </filter>
</appender>

<logger name="com.emp.sin.orcmultemp.service" additivity="false" >
    <level value="WARN" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE_SERVICE" />
    <appender-ref ref="FILE_ERR_SERVICE" />
</logger>

<logger name="org.springframework">
    <level value="WARN" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
    <appender-ref ref="FILE_ERR" />

</logger>

<logger name="org.hibernate">
    <level value="WARN" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
    <appender-ref ref="FILE_ERR" />
</logger>

<root>
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="FILE" />
</root> 

Using log4j:

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

public class MainClass {

    private static final Logger LOGGER = LogManager.getLogger(MainClass.class);
    LOGGER.info("TEST");
}
    
asked by anonymous 23.02.2016 / 19:03

0 answers