[英]spring Logback error coming when starting spring application
啟動部署在 Kube.netes 中的 spring 應用程序時出現以下 logback 錯誤。
2022-04-20 13:47:25.928 錯誤 1 --- [main] osboot.SpringApplication:應用程序運行失敗
java.lang.IllegalStateException:檢測到 Logback 配置錯誤:c.qlcore.rolling.SizeAndTimeBasedRollingPolicy@1248276879 中的錯誤 - 等待壓縮作業完成時出現意外異常 java.lang.InterruptedException 在 org.springframework.bootLogback.backLogging.System加載配置(LogbackLoggingSystem.java:169)在 org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:82)在 org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.89240gframe)或 89215888 .boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:117)在org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:290)在org.springframework.boot.context.logging.LoggingApplicationListener .initialize(LoggingApplicationListener.882132469458 88:263) 在 org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:226) 在 org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:199) 在 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) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) 在 org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) 在 org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) 在 org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347) 在 org.springframework.boot.SpringApplication.run(SpringApplication.8864308)4:8864308)在 com.dt.Application.main(Application.java:20) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImplating.java:6945888:6) 在 sun. (DelegatingMethodAccessorImpl.java:43)在 java.lang.reflect.Method.invoke(Method.java:498)在 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.88218588888:498)在 org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner4.88218588888:498) loader.Launcher.launch(Launcher.java:87) 在 org.springframework.boot.loader.Launcher.launch(Launcher.java:50) 在 org.springframework.boot.loader.JarLa uncher.main(JarLauncher.java:51)
Logback-spring 配置:-
<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>
任何克服此錯誤的想法都會有所幫助,因為它會停止主應用程序。
您的最大文件大小為 1GB 並指定 gzip 壓縮。 根據您在 pod 中的資源配置,這可能會導致執行壓縮的時間很長。
您可以增加資源,或者最好將最大文件大小減小到 100mb。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.