org.apache.logging.log4j.core.Logger.setAdditive()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(252)

本文整理了Java中org.apache.logging.log4j.core.Logger.setAdditive()方法的一些代码示例,展示了Logger.setAdditive()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.setAdditive()方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:setAdditive

Logger.setAdditive介绍

[英]This method is not exposed through the public API and is present only to support the Log4j 1.2 compatibility bridge.
[中]此方法不通过公共API公开,仅用于支持Log4j 1.2兼容桥。

代码示例

代码示例来源:origin: alibaba/nacos

@Override
public void setAdditivity(boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

protected void initRootLogger(final Appender appender) {
  root.addAppender(appender);
  root.setAdditive(false);
  root.setLevel(Level.DEBUG);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

final Logger root = context.getLogger("SMTPAppenderTest");
root.addAppender(appender);
root.setAdditive(false);
root.setLevel(Level.DEBUG);

代码示例来源:origin: mulesoft/mule

@Override
public void setAdditive(boolean additive) {
 getLogger().setAdditive(additive);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testUdpAppender() throws Exception {
  try {
    udpServer.latch.await();
  } catch (final InterruptedException ex) {
    ex.printStackTrace();
  }
  // @formatter:off
  final SocketAppender appender = SocketAppender.newBuilder()
      .withProtocol(Protocol.UDP)
      .withPort(tcpServer.getLocalPort())
      .withReconnectDelayMillis(-1)
      .withName("test")
      .withImmediateFail(false)
      .withLayout(JsonLayout.newBuilder().setProperties(true).build())
      .build();
  // @formatter:on
  appender.start();
  // set appender on root and set level to debug
  logger.addAppender(appender);
  logger.setAdditive(false);
  logger.setLevel(Level.DEBUG);
  logger.debug("This is a udp message");
  final LogEvent event = udpServer.getQueue().poll(3, TimeUnit.SECONDS);
  assertNotNull("No event retrieved", event);
  assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a udp message"));
  assertTrue("Message not delivered via UDP", udpServer.getCount() > 0);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

logger.setAdditive(false);
logger.setLevel(Level.DEBUG);
final String tcKey = "UUID";

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testTcpAppenderDeadlock() throws Exception {
  // @formatter:off
  final SocketAppender appender = SocketAppender.newBuilder()
      .withHost("localhost")
      .withPort(DYN_PORT)
      .withReconnectDelayMillis(100)
      .withName("test")
      .withImmediateFail(false)
      .withLayout(JsonLayout.newBuilder().setProperties(true).build())
      .build();
  // @formatter:on
  appender.start();
  // set appender on root and set level to debug
  logger.addAppender(appender);
  logger.setAdditive(false);
  logger.setLevel(Level.DEBUG);
  final TcpSocketTestServer tcpSocketServer = new TcpSocketTestServer(DYN_PORT);
  try {
    tcpSocketServer.start();
    logger.debug("This message is written because a deadlock never.");
    final LogEvent event = tcpSocketServer.getQueue().poll(3, TimeUnit.SECONDS);
    assertNotNull("No event retrieved", event);
  } finally {
    tcpSocketServer.shutdown();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@Test
public void testTcpAppenderNoWait() throws Exception {
  // @formatter:off
  final SocketAppender appender = SocketAppender.newBuilder()
      .withHost("localhost")
      .withPort(ERROR_PORT)
      .withReconnectDelayMillis(100)
      .withName("test")
      .withImmediateFail(false)
      .withIgnoreExceptions(false)
      .withLayout(JsonLayout.newBuilder().setProperties(true).build())
      .build();
  // @formatter:on
  appender.start();
  // set appender on root and set level to debug
  logger.addAppender(appender);
  logger.setAdditive(false);
  logger.setLevel(Level.DEBUG);
  try {
    logger.debug("This message is written because a deadlock never.");
    fail("No Exception was thrown");
  } catch (final Exception ex) {
    // TODO: move exception to @Test(expect = Exception.class)
    // Failure is expected.
    // ex.printStackTrace();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-1.2-api

public void setAdditivity(final boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: com.alibaba.edas.acm/acm-sdk

@Override
public void setAdditivity(boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: com.alibaba.nacos/nacos-client

@Override
public void setAdditivity(boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: com.taobao.middleware/logger.core

@Override
public void setAdditivity(boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: org.apache.logging.log4j.adapters/log4j-1.2-api

public void setAdditivity(final boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: org.apache.logging.log4j/log4j12-api

public void setAdditivity(boolean additivity) {
  logger.setAdditive(additivity);
}

代码示例来源:origin: org.mule.modules/mule-module-launcher

@Override
public void setAdditive(boolean additive)
{
  getLogger().setAdditive(additive);
}

代码示例来源:origin: org.mule.runtime/mule-module-launcher

@Override
public void setAdditive(boolean additive) {
 getLogger().setAdditive(additive);
}

代码示例来源:origin: alipay/sofa-common-tools

private void resetLog(Logger logger) {
    logger.getAppenders().clear();
    logger.addAppender(consoleAppender);
    logger.setLevel(getConsoleLevel(spaceId.getSpaceName(), properties));
    logger.setAdditive(false);
  }
});

相关文章