Log4j is not generating log backup

Asked

Viewed 89 times

2

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

I configured 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 limit size.

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> 

Use of 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");
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.