我在spring-boot(1.5.3.RELEASE)应用程序中使用AsyncAppender。在Spring Boot中定义logback shutdown hook
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运行时 停止LoggerContext正确在JVM关机已启动后
我想知道如何将st在Spring Boot应用程序中运行AsyncAppender。在Spring Boot的哪个位置,我应该定义关闭挂钩吗?