当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

[logback]程序退出时flush log

发表于: 2013-12-06   作者:aigo   来源:转载   浏览:
摘要: 原文:http://stackoverflow.com/questions/3678755/do-i-need-to-flush-events-when-shutting-down-using-logback Here's a simple approach: import org.slf4j.ILoggerFactory; import org.slf4j.Logger; import

原文:http://stackoverflow.com/questions/3678755/do-i-need-to-flush-events-when-shutting-down-using-logback

Here's a simple approach:

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.LoggerContext;

...

ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
// Check for logback implementation of slf4j
if (loggerFactory instanceof LoggerContext) {
    LoggerContext context = (LoggerContext) loggerFactory;
    context.stop();
}

 

[logback]程序退出时flush log

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号