当前位置: 首页>>代码示例>>Java>>正文


Java LoggerContext.getLoggerList方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.LoggerContext.getLoggerList方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.getLoggerList方法的具体用法?Java LoggerContext.getLoggerList怎么用?Java LoggerContext.getLoggerList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.LoggerContext的用法示例。


在下文中一共展示了LoggerContext.getLoggerList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setMetricsMarkerLogbackFilter

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();

    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext();) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:25,代码来源:LoggingConfiguration.java

示例2: setMetricsMarkerLogbackFilter

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private void setMetricsMarkerLogbackFilter(LoggerContext context) {
    log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
    OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
    onMarkerMetricsEvaluator.setContext(context);
    onMarkerMetricsEvaluator.addMarker("metrics");
    onMarkerMetricsEvaluator.start();
    EvaluatorFilter<ILoggingEvent> metricsFilter = new EvaluatorFilter<>();
    metricsFilter.setContext(context);
    metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
    metricsFilter.setOnMatch(FilterReply.DENY);
    metricsFilter.start();

    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        for (Iterator<Appender<ILoggingEvent>> it = logger.iteratorForAppenders(); it.hasNext(); ) {
            Appender<ILoggingEvent> appender = it.next();
            if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
                log.debug("Filter metrics logs from the {} appender", appender.getName());
                appender.setContext(context);
                appender.addFilter(metricsFilter);
                appender.start();
            }
        }
    }
}
 
开发者ID:asanzdiego,项目名称:codemotion-2017-taller-de-jhipster,代码行数:25,代码来源:LoggingConfiguration.java

示例3: getLogFromLogback

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的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

示例4: figureOutLogBackConfig

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
 * figure out the logback's configuration: for example, appenders' file path, buff io, etc...
 * 
 * @param context
 * @param webapploader
 */
private void figureOutLogBackConfig(HookContext context, ClassLoader webapploader) {

    Logger logback = (Logger) LoggerFactory.getLogger(LogBackHookProxy.class);

    InterceptContext interceptContext = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT);

    if (interceptContext == null) {
        logback.warn("No InterceptContext available, can't figure out LogBack configuration.");
        return;
    }

    @SuppressWarnings("unchecked")
    LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) interceptContext
            .get(HookConstants.LOG_PROFILE_LIST);

    if (null == list) {
        list = new LinkedList<LogProfileInfo>();
        interceptContext.put(HookConstants.LOG_PROFILE_LIST, list);
    }

    String appid = (String) (interceptContext.get(InterceptConstants.CONTEXTPATH));

    // figureour all loggers
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    List<ch.qos.logback.classic.Logger> loggers = loggerContext.getLoggerList();

    for (Logger logger : loggers) {
        figureoutLogConfiguration(logger, list, appid);
    }

}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:39,代码来源:LogBackHookProxy.java

示例5: initLogger

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
 * Initialize the logger, in order to display all the log messages in a text
 * logger on the gui.
 */
private void initLogger() {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

    // find the appender which is an instance of the text area appender and set the text area where it should put the text
    for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
        // iterate the appenders in order to find the wanted one
        for (Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext();) {
            Appender<ILoggingEvent> appender = index.next();
            // just the TextAreaAppender type is needed to be correctly initialised
            if (appender instanceof TextAreaAppender) {
                ((TextAreaAppender) appender).setTextArea(jTALog, jTAShortLog);
            }
        }
    }
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:20,代码来源:GUILabelingTool.java

示例6: LogWindow

import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
/**
 * Constructor
 */
public LogWindow(final Window parent) {
	super(parent, "Log", ModalityType.DOCUMENT_MODAL);
	final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	for (final ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
		for (final Iterator<ch.qos.logback.core.Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext();) {
			final ch.qos.logback.core.Appender<ILoggingEvent> appender = index.next();
			if (appender instanceof Appender) {
				_appender = (Appender) appender;
				break;
			}
		}
	}
	_logs = new JTextPane() {
		@Override
		public boolean getScrollableTracksViewportWidth() {
			return getUI().getPreferredSize(this).width <= getParent().getSize().width;
		}
	};
	if (_appender != null) {
		_appender.display = this;
	}
	try {
		for (final String line : Util.readUTF8File(new FileInputStream(Env.LOG_FILE))) {
			appendFormatted(line + "\n");
		}
	} catch (final FileNotFoundException e1) {
		appendFormatted("Failed to open file " + Env.LOG_FILE.getAbsolutePath());
	}
	final JScrollPane scroll = new JScrollPane(_logs, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	scroll.setPreferredSize(new Dimension(800, 600));
	getContentPane().add(scroll, BorderLayout.CENTER);
	final JButton close = new JButton(Resources.getLabel("close.button"));
	close.addActionListener(e -> LogWindow.this.dispose());
	getContentPane().add(close, BorderLayout.SOUTH);
	SwingUtilities4.setUp(this);
	getRootPane().registerKeyboardAction(e -> {
		_appender.display = null;
		dispose();
		if (parent != null) {
			parent.toFront();
		}
	}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:47,代码来源:LogWindow.java


注:本文中的ch.qos.logback.classic.LoggerContext.getLoggerList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。