'Logback stops logging while application is running
I am using springboot 2.2.6.RELEASE and I also have the following jars for log4j (I have an old 3rd party library (Filenet jars) that requires log4j class org.apache.log4j.Priority to be present on classpath on runtime)
I am using log4j-1.2-api compatibility api to allow the application to use use Log4j 2 instead of Log4j 1.2 API since org.apache.log4j.Priority exists in log4j-1.2 which I don't want to use because it has vulnerabilities and I want to transform the code to Log4j 2
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>2.16.0</version>
</dependency>
my logback.xml is as follows :
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="120 seconds">
<!--
reference here : http://logback.qos.ch/manual/layouts.html
%d : 2006-10-20 14:06:49,812
%-5level : the level of the logging event should be left justified to a width of five characters
logger{length} : shorten the logger class name
-->
<property name="logPattern" value="%d %-5level %logger{35} - %msg%n"/>
<property name="logEncoding" value="UTF-8"/>
<property name="logDirectory" value="C:\\MYAPP_LOGS"/>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>${logEncoding}</charset>
<pattern>${logPattern}</pattern>
</encoder>
</appender>
<appender name="fileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logDirectory}/myapp.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logDirectory}/myapp.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<charset>${logEncoding}</charset>
<pattern>${logPattern}</pattern>
</encoder>
</appender>
<logger name="org.springframework.security" level="ERROR"/>
<logger name="org.primefaces" level="ERROR"/>
<logger name="com.ocpsoft" level="ERROR"/>
<logger name="com.myapp" level="DEBUG"/>
<root level="INFO">
<appender-ref ref="fileAppender"/>
<appender-ref ref="console" />
</root>
</configuration>
The application runs on tomcat 9.0.34 standalone windows service
ISSUE: sometimes for no obvious reason the application stops writing to log file and I want to find out what causes the issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
