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


Java LoggerConfig.removeAppender方法代碼示例

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


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

示例1: updateAppenders

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
private void updateAppenders(LoggerConfig loggerConfig, Iterable<String> appendersRef){
	Map<String,Appender> appenders = loggerConfig.getAppenders();
	for(String string : appenders.keySet()){
		loggerConfig.removeAppender(string);
	}
	for(String appenderRef : appendersRef){
		Appender appender = config.getAppender(appenderRef);
		if(appender != null){
			loggerConfig.addAppender(appender, null, null);
		}else{
			logger.error("Appender \"" + appenderRef + "\" not found");
		}
	}
}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:15,代碼來源:Log4j2Configurator.java

示例2: after

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
@Override
protected void after() {
    if (loggerClass == null) {
        return;
    }

    final LoggerContext ctx = getLoggerContext();
    LoggerConfig loggerConfig = ctx.getConfiguration().getLoggerConfig(loggerClass.getName());
    loggerConfig.setLevel(oldLevel);
    loggerConfig.removeAppender(APPENDER_NAME);
    ctx.updateLoggers();
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:13,代碼來源:LogTestRule.java

示例3: removeConsoleAppender

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
/**
 * Removes STDOUT ConsoleAppender from ROOT logger. Only called when using the log4j2-default.xml
 * configuration. This is done when creating the LogWriterAppender for log-file. The Appender
 * instance is stored in stdoutAppender so it can be restored later using restoreConsoleAppender.
 */
public static synchronized void removeConsoleAppender() {
  final AppenderContext appenderContext =
      LogService.getAppenderContext(LogService.ROOT_LOGGER_NAME);
  final LoggerConfig config = appenderContext.getLoggerConfig();
  Appender stdout = config.getAppenders().get(STDOUT);
  if (stdout != null) {
    config.removeAppender(STDOUT);
    stdoutAppender = stdout;
    appenderContext.getLoggerContext().updateLoggers();
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:17,代碼來源:LogService.java

示例4: removeAppender

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
private void removeAppender(String name) {
    final LoggerContext context = LoggerContext.getContext(false);
    final org.apache.logging.log4j.core.config.Configuration config = context.getConfiguration();

    for (final LoggerConfig loggerConfig : config.getLoggers().values()) {
        loggerConfig.removeAppender(name);
    }
    config.getRootLogger().removeAppender(name);
    context.updateLoggers();
}
 
開發者ID:graylog-labs,項目名稱:graylog-plugin-internal-logs,代碼行數:11,代碼來源:SerializedLogEventTransport.java

示例5: deregister

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
void deregister() {
	if (LogManager.getContext(false) instanceof LoggerContext) {
		final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
		if (ctx.getConfiguration() instanceof AbstractConfiguration) {
			final AbstractConfiguration config = (AbstractConfiguration) ctx.getConfiguration();
			final Appender appender = getSingleton();
			appender.stop();
			config.removeAppender(appender.getName());
			final Logger rootLogger = LogManager.getRootLogger();
			final LoggerConfig loggerConfig = config.getLoggerConfig(rootLogger.getName());
			loggerConfig.removeAppender(appender.getName());
			ctx.updateLoggers();
		}
	}
}
 
開發者ID:javamelody,項目名稱:javamelody,代碼行數:16,代碼來源:Log4J2Appender.java

示例6: setThreshold

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
@Override
public void setThreshold(String level) {
  Log4j2Appender app = getAppender();
  Level current = app.getThreshold();
  app.setThreshold(Level.toLevel(level));
  LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
  LoggerConfig config = getLoggerConfig(ctx, LoggerInfo.ROOT_NAME);
  config.removeAppender(app.getName());
  config.addAppender(app, app.getThreshold(), app.getFilter());
  ((LoggerContext)LogManager.getContext(false)).updateLoggers();
  watcherLog.info("Updated watcher threshold from "+current+" to " + level);
}
 
開發者ID:lucidworks,項目名稱:solr-log4j2,代碼行數:13,代碼來源:Log4j2Watcher.java

示例7: addRootApender

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
/**
 * Adds the specified appender to the root logger.
 * 
 * @param appender
 *            the appender
 * @param level
 *            the logging level to assign to the appender. Default is INFO
 */
public static synchronized void addRootApender(Appender appender, String level) {
	Configuration config = getConfiguration();
	appender.start();
	config.addAppender(appender);
	Level l = Level.toLevel(level, Level.INFO);

	LoggerConfig root = config.getRootLogger();
	if (!root.getLevel().isLessSpecificThan(l)) {
		if (originalRootLevel == null) {
			originalRootLevel = root.getLevel();
			Iterator<AppenderRef> it = root.getAppenderRefs().iterator();
			while (it.hasNext()) {
				AppenderRef ar = it.next();
				if (ar.getLevel() == null) {
					Appender a = root.getAppenders().get(ar.getRef());
					root.removeAppender(a.getName());
					root.addAppender(a, originalRootLevel, ar.getFilter());
				}
			}
		}
		root.setLevel(l);
	}
	root.addAppender(appender, l, null);
	addedAppenders++;
	getContext().updateLoggers();
}
 
開發者ID:sfera-labs,項目名稱:sfera,代碼行數:35,代碼來源:LoggerUtils.java

示例8: removeRootApender

import org.apache.logging.log4j.core.config.LoggerConfig; //導入方法依賴的package包/類
/**
 * Removes the specified previously added appender from the root logger.
 * 
 * @param appender
 *            the appender to remove
 */
public static synchronized void removeRootApender(Appender appender) {
	if (addedAppenders > 0) {
		Configuration config = getConfiguration();
		String name = appender.getName();
		LoggerConfig root = config.getRootLogger();
		root.removeAppender(name);
		appender.stop();
		if (--addedAppenders == 0 && originalRootLevel != null) {
			root.setLevel(originalRootLevel);
		}
		getContext().updateLoggers();
	}
}
 
開發者ID:sfera-labs,項目名稱:sfera,代碼行數:20,代碼來源:LoggerUtils.java


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