当前位置: 首页>>代码示例>>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;未经允许,请勿转载。