Logback generated different files when running on local and server

55 Views Asked by At

It appears that Logback generated different files when running the application on the local machine compared to when it was run on the server.

I have a logback file like this

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <!-- TODO It should use Relative Path instead absolute path -->
    <!-- Default -->
    <property name="LOG_PATH" value="logs" />
    <property name="LOG_NAME" value="app.log" />

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
          <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
        </layout>
    </appender>
   
    <appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/${LOG_NAME}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <fileNamePattern>${CATALINA_HOME}/${LOG_PATH}/${LOG_NAME}-%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
            <maxFileSize>10MB</maxFileSize>    
            <maxHistory>50</maxHistory>
            <totalSizeCap>50MB</totalSizeCap>
        </rollingPolicy>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss:SSS} %5p %t %c{2}:%L - %m%n</pattern>
        </encoder>
    </appender>
    
    <logger name="com.xyz.xxx.xxx.management" level="INFO" additivity="false">
        <appender-ref ref="STDOUT"/>    
        <appender-ref ref="LOG_FILE" />
    </logger>

    <logger name="org.springframework" level="ERROR" additivity="false">
        <appender-ref ref="STDOUT"/>    
        <appender-ref ref="LOG_FILE" />
    </logger>
    
    <root level="INFO">
        <appender-ref ref="STDOUT" />
    </root>
      
</configuration>

I was able to generate the correct log file when I tested the application on my local machine (app.log for active log file and zipped file in folder CATALINA_HOME_IS_UNDEFINED). However, when I ran it on a server, the application generated different files such as xyzportaltest-stdout.2023-10-24.log, xyzportaltest-stderr.2023-10-24.log, and catalina.2023-10-25.log. The issue is that the size of the file xyzportaltest-stdout.2023-10-24.log is 120,383KB instead of the configured 10MB in logback.xml. Can you please help me understand what went wrong and provide some guidance on how to resolve this issue? Thank you in advance for your assistance.

I attempted to remove the stdout appender statement but was unsuccessful. Although I tried to locate the log4j.xml configuration in my project, it was not found. Additionally, I was unable to find the configuration for Lombok.

0

There are 0 best solutions below