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


Java Logger.removeAppender方法代碼示例

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


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

示例1: onDisable

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Override
public void onDisable() {
    //restore the old format
    Appender terminalAppender = CommonLogInstaller.getTerminalAppender(TERMINAL_NAME);
    Logger rootLogger = ((Logger) LogManager.getRootLogger());

    ColorPluginAppender colorPluginAppender = null;
    for (Appender value : rootLogger.getAppenders().values()) {
        if (value instanceof ColorPluginAppender) {
            colorPluginAppender = (ColorPluginAppender) value;
            break;
        }
    }

    if (colorPluginAppender != null) {
        rootLogger.removeAppender(terminalAppender);
        rootLogger.addAppender(colorPluginAppender.getOldAppender());
    }

    try {
        CommonLogInstaller.setLayout(oldLayout, terminalAppender);
    } catch (ReflectiveOperationException ex) {
        getLogger().log(Level.WARNING, "Cannot revert log format", ex);
    }
}
 
開發者ID:games647,項目名稱:ColorConsole,代碼行數:26,代碼來源:ColorConsoleBukkit.java

示例2: call

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
public Object call() throws Exception {
  // Setup for capturing logger messages
  Appender mockAppender = mock(Appender.class);
  when(mockAppender.getName()).thenReturn("MockAppender");
  when(mockAppender.isStarted()).thenReturn(true);
  when(mockAppender.isStopped()).thenReturn(false);
  Logger logger = (Logger) LogManager.getLogger(ColocationLogger.class);
  logger.addAppender(mockAppender);
  logger.setLevel(Level.WARN);
  loggingEventCaptor = ArgumentCaptor.forClass(LogEvent.class);

  // Logger interval may have been hooked by the test, so adjust test delays here
  int logInterval = ColocationLogger.getLogInterval();
  List<LogEvent> logEvents = Collections.emptyList();

  AtomicBoolean isDone = new AtomicBoolean(false);
  try {
    createPR(PR_REGION_NAME, true);
    // Let this thread continue running long enough for the missing region to be logged a
    // couple times.
    // Child regions do not get created by this thread.
    await().atMost(MAX_WAIT, TimeUnit.MILLISECONDS).until(() -> {
      verify(mockAppender, times(numExpectedLogMessages))
          .append(loggingEventCaptor.capture());
    });
    // createPR("region2", PR_REGION_NAME, true); // This child region is never created
  } finally {
    logEvents = loggingEventCaptor.getAllValues();
    assertEquals(String.format("Expected %d messages to be logged, got %d.",
        numExpectedLogMessages, logEvents.size()), numExpectedLogMessages,
        logEvents.size());
    String logMsg = logEvents.get(0).getMessage().getFormattedMessage();
    logger.removeAppender(mockAppender);
    numExpectedLogMessages = 1;
    return logMsg;
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:38,代碼來源:PersistentColocatedPartitionedRegionDUnitTest.java

示例3: installAppender

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
public static void installAppender(Appender colorAppender, String terminalName) {
    Logger rootLogger = (Logger) LogManager.getRootLogger();

    colorAppender.start();

    rootLogger.removeAppender(getTerminalAppender(terminalName));
    rootLogger.addAppender(colorAppender);
}
 
開發者ID:games647,項目名稱:ColorConsole,代碼行數:9,代碼來源:CommonLogInstaller.java

示例4: loadLogAppender

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
private boolean loadLogAppender()
{
	Logger log = (Logger)LogManager.getRootLogger();
	for(Appender appender : log.getAppenders().values())
	{
		if(appender instanceof RConsoleAppender)
			log.removeAppender(appender);
	}
	
	mAppender = new RConsoleAppender(new DefaultConfiguration());
	mAppender.start();
	log.addAppender(mAppender);
	
	return true;
}
 
開發者ID:Schmoller,項目名稱:BetterRCon,代碼行數:16,代碼來源:BetterRCon.java

示例5: testStructured

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test
public void testStructured() throws InterruptedException, IOException {
    final Agent[] agents = new Agent[] { Agent.createAgent("localhost",
            testPort) };
    final FlumeAppender avroAppender = FlumeAppender.createAppender(agents,
            null, "false", "Avro", null, "1000", "1000", "1", "1000",
            "avro", "false", null, null, null, "ReqCtx_", null, "true",
            "1", null, null, null, null);
    avroAppender.start();
    final Logger eventLogger = (Logger) LogManager.getLogger("EventLogger");
    Assert.assertNotNull(eventLogger);
    eventLogger.addAppender(avroAppender);
    eventLogger.setLevel(Level.ALL);

    final StructuredDataMessage msg = new StructuredDataMessage("Transfer",
            "Success", "Audit");
    msg.put("memo", "This is a memo");
    msg.put("acct", "12345");
    msg.put("amount", "100.00");
    ThreadContext.put("id", UUID.randomUUID().toString());
    ThreadContext.put("memo", null);
    ThreadContext.put("test", "123");

    EventLogger.logEvent(msg);

    final Transaction transaction = channel.getTransaction();
    transaction.begin();

    final Event event = channel.take();
    Assert.assertNotNull(event);
    Assert.assertTrue("Channel contained event, but not expected message",
            getBody(event).endsWith("Success"));
    transaction.commit();
    transaction.close();

    eventSource.stop();
    eventLogger.removeAppender(avroAppender);
    avroAppender.stop();
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:40,代碼來源:FlumeAppenderTest.java

示例6: testStructured

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
@Test
public void testStructured() throws IOException {
    final Agent[] agents = new Agent[] { Agent.createAgent("localhost",
            testPort) };
    final FlumeAppender avroAppender = FlumeAppender.createAppender(agents,
            null, null, "false", "Avro", null, "1000", "1000", "1", "1000",
            "avro", "false", null, null, null, "ReqCtx_", null, "true",
            "1", null, null, null, null);
    avroAppender.start();
    final Logger eventLogger = (Logger) LogManager.getLogger("EventLogger");
    Assert.assertNotNull(eventLogger);
    eventLogger.addAppender(avroAppender);
    eventLogger.setLevel(Level.ALL);

    final StructuredDataMessage msg = new StructuredDataMessage("Transfer",
            "Success", "Audit");
    msg.put("memo", "This is a memo");
    msg.put("acct", "12345");
    msg.put("amount", "100.00");
    ThreadContext.put("id", UUID.randomUUID().toString());
    ThreadContext.put("memo", null);
    ThreadContext.put("test", "123");

    EventLogger.logEvent(msg);

    final Transaction transaction = channel.getTransaction();
    transaction.begin();

    final Event event = channel.take();
    Assert.assertNotNull(event);
    Assert.assertTrue("Channel contained event, but not expected message", getBody(event).endsWith("Success"));
    transaction.commit();
    transaction.close();

    eventSource.stop();
    eventLogger.removeAppender(avroAppender);
    avroAppender.stop();
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:39,代碼來源:FlumeAppenderTest.java

示例7: close

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
public void close() {
    Logger logger = (Logger) LogManager.getLogger(this.getName());
    logger.removeAppender(this);
    super.clear();
}
 
開發者ID:greenbird,項目名稱:mule-access-log,代碼行數:6,代碼來源:LayoutTestLogAppender.java

示例8: removeAppenders

import org.apache.logging.log4j.core.Logger; //導入方法依賴的package包/類
private static void removeAppenders(final Logger root) {
    final Map<String, Appender> appenders = root.getAppenders();
    for (final Appender appender : appenders.values()) {
        root.removeAppender(appender);
    }
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:7,代碼來源:CsvParameterLayoutTest.java


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