當前位置: 首頁>>代碼示例>>Java>>正文


Java Logger.iteratorForAppenders方法代碼示例

本文整理匯總了Java中ch.qos.logback.classic.Logger.iteratorForAppenders方法的典型用法代碼示例。如果您正苦於以下問題:Java Logger.iteratorForAppenders方法的具體用法?Java Logger.iteratorForAppenders怎麽用?Java Logger.iteratorForAppenders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.classic.Logger的用法示例。


在下文中一共展示了Logger.iteratorForAppenders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLogFromLogback

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private static Path getLogFromLogback( final File logbackConfig )
{
    try
    {
        LoggerContext loggerContext = new LoggerContext();
        JoranConfigurator jc = new JoranConfigurator();
        jc.setContext( loggerContext );
        loggerContext.reset();
        jc.doConfigure( logbackConfig );

        for ( Logger logger : loggerContext.getLoggerList() )
        {
            for ( Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); )
            {
                Appender<ILoggingEvent> appender = index.next();
                if ( appender instanceof FileAppender )
                {
                    return Paths.get( ( (FileAppender) appender ).getFile() );
                }
            }
        }
        return null;
    }
    catch ( Exception e )
    {
        return null;
    }
}
 
開發者ID:aro,項目名稱:app-logbrowser,代碼行數:29,代碼來源:LogHelper.java

示例2: figureoutLogConfiguration

import ch.qos.logback.classic.Logger; //導入方法依賴的package包/類
private void figureoutLogConfiguration(Logger Logger, LinkedList<LogProfileInfo> list, String appid) {

        Iterator<Appender<ILoggingEvent>> appenders = Logger.iteratorForAppenders();

        while (appenders != null && appenders.hasNext()) {

            LogProfileInfo logProfileInfo = new LogProfileInfo();

            if (appid != null) {
                logProfileInfo.setAppId(appid);
            }

            logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j);

            Map<String, String> attributes = new HashMap<String, String>();

            attributes.put(LogProfileInfo.ENGINE, "logback");

            Appender<ILoggingEvent> appender = appenders.next();

            if (!(appender instanceof FileAppender<?>)) {
                continue;
            }

            FileAppender<ILoggingEvent> fileAppender = (FileAppender<ILoggingEvent>) appender;
            @SuppressWarnings("rawtypes")
            LayoutWrappingEncoder encoder = (LayoutWrappingEncoder) fileAppender.getEncoder();

            Layout<?> layout = encoder.getLayout();

            if (null != layout) {

                if (layout instanceof PatternLayout) {
                    PatternLayout patternLayout = (PatternLayout) encoder.getLayout();
                    attributes.put(LogProfileInfo.PATTERN, patternLayout.getPattern());
                }
                else if (layout instanceof HTMLLayout) {
                    attributes.put(LogProfileInfo.PATTERN, "HTMLLayout");
                }
                else if (layout instanceof XMLLayout) {
                    attributes.put(LogProfileInfo.PATTERN, "XMLLayout");
                }
                else if (layout instanceof TTLLLayout) {
                    attributes.put(LogProfileInfo.PATTERN, "TTCCLayout");
                }
            }

            logProfileInfo.setFilePath(fileAppender.getFile());
            logProfileInfo.setAttributes(attributes);

            list.add(logProfileInfo);

        }
    }
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:55,代碼來源:LogBackHookProxy.java


注:本文中的ch.qos.logback.classic.Logger.iteratorForAppenders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。