【发布时间】:2018-01-23 09:20:54
【问题描述】:
我在 spring-boot (1.5.3.RELEASE) 应用程序中使用 AsyncAppender。
logback.xml
<appender name="FILE_ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<queueSize>5000</queueSize>
<discardingThreshold>0</discardingThreshold>
<appender-ref ref="FILE" />
</appender>
根据 logback 文档,
在应用程序关闭或重新部署时,必须停止 AsyncAppender 为了停止和回收工作线程并刷新 从队列中记录事件。
https://logback.qos.ch/manual/appenders.html
进一步说:
为了避免打断这些下的工作线程 条件下,可以将关闭钩子插入到 JVM 运行时中 在启动 JVM 关闭后正确停止 LoggerContext
我想知道如何在 Spring Boot 应用程序中停止 AsyncAppender。在 Spring Boot 的哪个地方,我应该定义关闭钩子?
【问题讨论】:
标签: spring-boot logback