prateek jangid
prateek jangid

Reputation: 85

spring Logback error coming when starting spring application

Below logback error is coming when starting the spring application which is deployed in Kubernetes.

2022-04-20 13:47:25.928 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

java.lang.IllegalStateException: Logback configuration error detected: ERROR in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1248276879 - Unexpected exception while waiting for compression job to finish java.lang.InterruptedException at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:169) at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:82) at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60) at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:117) at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:290) at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:263) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:226) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:199) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) at com.dt.Application.main(Application.java:20) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)

Logback-spring configuration:-

<appender name="FILE-JSON-LIBS"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_DIR}/${dtlogname:-${ACTIVE_APP}}-${envname:-${ENV}}-libs-json-${HOSTNAME}.log</file>

        <encoder class="net.logstash.logback.encoder.LogstashEncoder">
            <timeZone>UTC</timeZone>
            <timestampPattern>dd-MM-yyyy HH:mm:ss:SSS</timestampPattern>
            <shortenedLoggerNameLength>25</shortenedLoggerNameLength>
            <fieldNames>
                <timestamp>requestTimeStamp</timestamp>
                <thread>threadId</thread>
                <logger>logger</logger>
                <stackTrace>stackTrace</stackTrace>
                <version>[ignore]</version>
                <levelValue>[ignore]</levelValue>
            </fieldNames>
            <includeMdcKeyName>REQUEST_ID</includeMdcKeyName>
            <includeMdcKeyName>CORRELATION_ID</includeMdcKeyName>
            <includeMdcKeyName>COUNTRY</includeMdcKeyName>
            <includeMdcKeyName>LANGUAGE</includeMdcKeyName>
            <includeMdcKeyName>CHANNEL</includeMdcKeyName>
            <mdcKeyFieldName>REQUEST_ID=requestId</mdcKeyFieldName>
            <mdcKeyFieldName>CORRELATION_ID=correlationId</mdcKeyFieldName>
            <mdcKeyFieldName>COUNTRY=country</mdcKeyFieldName>
            <mdcKeyFieldName>LANGUAGE=language</mdcKeyFieldName>
            <mdcKeyFieldName>CHANNEL=channel</mdcKeyFieldName>
            <includeContext>false</includeContext>
            <customFields>{"serviceId":"${ACTIVE_APP}"}</customFields>
        </encoder>

        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>
                ${LOG_DIR}/${dtlogname:-${ACTIVE_APP}}-${envname:-${ENV}}-libs-json-${HOSTNAME}.%d{yyyy-MM-dd}.%i.gz
            </fileNamePattern>
            <maxFileSize>1GB</maxFileSize>
            <totalSizeCap>10GB</totalSizeCap>
            <!-- keep 30 days worth of history -->
            <maxHistory>30</maxHistory>
        </rollingPolicy>
    </appender>

Any idea to overcome this error will be helpful as it stops the main application.

Upvotes: 0

Views: 521

Answers (1)

Thomas
Thomas

Reputation: 12019

You have a maximum filesize of 1GB and specify gzip compression. Depending on your resource configuration in the pod this can lead to quite a long time for performing the compression.

You can either increase the resources or, probably better, reduce the max file size to 100mb.

Upvotes: 0

Related Questions