Logback 配置中的 BuferredIO 和 ImmediateFlush 属性
BuferredIO and ImmediateFlush properties in Logback configuration
我正在将旧版应用程序迁移到 Spring Boot,我遇到了以下问题:当我启动该应用程序时,由于以下异常而失败:
Exception in thread "main" java.lang.IllegalStateException: Logback
configuration error detected: ERROR in
ch.qos.logback.core.joran.spi.Interpreter@10:21 - no applicable action
for [BufferedIO], current ElementPath is
[[configuration][appender][BufferedIO]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:25 - no
applicable action for [ImmediateFlush], current ElementPath is
[[configuration][appender][ImmediateFlush]]
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:161)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:207)
at
org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65)
at
org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114)
at
org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:299)
at
org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:272)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:235)
at
org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:208)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at
org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:72)
at
org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at
org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:309)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1187)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1176)
at com.some_company.SomeApp.main(SomeApp.java:28)
因此 Logback 无法解析 BuferredIO 和 ImmediateFlush 属性。我试图查看他们的 docs 但它似乎已过时,因为它说存在此类属性 + 我发现例如对于 OutputStreamAppender
它没有 immediateFlush
属性 而根据它应该的文档。
我找不到任何关于 Logback 现在是否仍然支持以下属性的信息。您能否帮助我提出一些关于如何获得与以前的属性相同的结果的想法?也许他们在别的地方:)
非常感谢!:)
更新: 添加 Logback 配置快照:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logdir}/some-app.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${logdir}/archive-some-app.%i.log.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>20MB</MaxFileSize>
</triggeringPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<fieldNames>
<timestamp>timestamp</timestamp>
</fieldNames>
</encoder>
</appender>
Logback 版本为 1.1.7(之前是迁移之前)
尽管 ImmediateFlush
是 2017 年 2 月 OutputStreamAppender (which RollingFileAppender
extends) in the latest version of Logback (and hence is referenced in the latest docs) this was only added to OutputStreamAppender
here 的有效配置 属性。因此,immediateFlush
不是 [=12 的有效 属性 =](因此在 v1.1.7
中无法从 RollingFileAppender
访问)
这解释了以下错误:
no applicable action for [ImmediateFlush], current ElementPath is [[configuration][appender][ImmediateFlush]]
BufferedIO
是旧配置 属性,Logback 不再支持它。
这解释了以下错误:
no applicable action for [BufferedIO], current ElementPath is [[configuration][appender][BufferedIO]]
总而言之,您可以考虑升级到最新的 Logback 并删除 <BufferedIO>false</BufferedIO>
。或者,继续使用 v1.1.7 并删除这两个:<BufferedIO>false</BufferedIO>
和 <ImmediateFlush>true</ImmediateFlush>
.
我正在将旧版应用程序迁移到 Spring Boot,我遇到了以下问题:当我启动该应用程序时,由于以下异常而失败:
Exception in thread "main" java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:21 - no applicable action for [BufferedIO], current ElementPath is [[configuration][appender][BufferedIO]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@11:25 - no applicable action for [ImmediateFlush], current ElementPath is [[configuration][appender][ImmediateFlush]]
at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:161) at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:207) at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65) at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50) at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114) at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:299) at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:272) at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:235) at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:208) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122) at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:72) at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:338) at org.springframework.boot.SpringApplication.run(SpringApplication.java:309) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176) at com.some_company.SomeApp.main(SomeApp.java:28)
因此 Logback 无法解析 BuferredIO 和 ImmediateFlush 属性。我试图查看他们的 docs 但它似乎已过时,因为它说存在此类属性 + 我发现例如对于 OutputStreamAppender
它没有 immediateFlush
属性 而根据它应该的文档。
我找不到任何关于 Logback 现在是否仍然支持以下属性的信息。您能否帮助我提出一些关于如何获得与以前的属性相同的结果的想法?也许他们在别的地方:)
非常感谢!:)
更新: 添加 Logback 配置快照:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${logdir}/some-app.log</File>
<Append>true</Append>
<BufferedIO>false</BufferedIO>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>${logdir}/archive-some-app.%i.log.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>20MB</MaxFileSize>
</triggeringPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<fieldNames>
<timestamp>timestamp</timestamp>
</fieldNames>
</encoder>
</appender>
Logback 版本为 1.1.7(之前是迁移之前)
尽管 ImmediateFlush
是 2017 年 2 月 OutputStreamAppender (which RollingFileAppender
extends) in the latest version of Logback (and hence is referenced in the latest docs) this was only added to OutputStreamAppender
here 的有效配置 属性。因此,immediateFlush
不是 [=12 的有效 属性 =](因此在 v1.1.7
RollingFileAppender
访问)
这解释了以下错误:
no applicable action for [ImmediateFlush], current ElementPath is [[configuration][appender][ImmediateFlush]]
BufferedIO
是旧配置 属性,Logback 不再支持它。
这解释了以下错误:
no applicable action for [BufferedIO], current ElementPath is [[configuration][appender][BufferedIO]]
总而言之,您可以考虑升级到最新的 Logback 并删除 <BufferedIO>false</BufferedIO>
。或者,继续使用 v1.1.7 并删除这两个:<BufferedIO>false</BufferedIO>
和 <ImmediateFlush>true</ImmediateFlush>
.