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

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

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

Logger.trace介绍

[英]Logs a message CharSequence with the Level#TRACE level.
[中]记录级别为#跟踪级别的消息字符序列。

代码示例

代码示例来源:origin: apache/geode

@Override
public void endListField(String fieldName) {
 if (logger.isTraceEnabled()) {
  logger.trace("endListField fieldName: {}", fieldName);
 }
}

代码示例来源:origin: apache/hive

/**
 * Indicate that the specified key is no longer used.
 * @param key
 */
private void keyComplete(String key) {
 Preconditions.checkNotNull(key, "Key must be specified");
 boolean removed = knownAppenders.remove(key);
 if (removed) {
  if (LOGGER.isDebugEnabled()) {
   LOGGER.debug("Deleting Appender for key: " + key);
  }
  routingAppender.deleteAppender(key);
 } else {
  LOGGER.trace("Ignoring call to remove unknown key: " + key);
 }
}

代码示例来源:origin: apache/geode

private Set<Object> readEntryKeySet(final int size, final DataInput in)
  throws IOException, ClassNotFoundException {
 if (logger.isTraceEnabled(LogMarker.SERIALIZER_VERBOSE)) {
  logger.trace(LogMarker.SERIALIZER_VERBOSE, "Reading HashSet with size {}", size);
 }
 final HashSet<Object> set = new HashSet<Object>(size);
 Object key;
 for (int i = 0; i < size; i++) {
  key = DataSerializer.readObject(in);
  set.add(key);
 }
 if (logger.isDebugEnabled()) {
  logger.debug("Read HashSet with {} elements: {}", size, set);
 }
 return set;
}

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

public static void main(final String[] args) {
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console-highlight-logback.xml")) {
    LOG.fatal("Fatal message.");
    LOG.error("Error message.");
    LOG.warn("Warning message.");
    LOG.info("Information message.");
    LOG.debug("Debug message.");
    LOG.trace("Trace message.");
    LOG.error("Error message.", new IOException("test"));
  }
}

代码示例来源:origin: apache/geode

@Override
public void process(DistributionManager dm, ReplyProcessor21 processor) {
 final long startTime = getTimestamp();
 final boolean isDebugEnabled = logger.isTraceEnabled(LogMarker.DM_VERBOSE);
 if (isDebugEnabled) {
  logger.trace(LogMarker.DM_VERBOSE,
    "FetchVersionReplyMessage process invoking reply processor with processorId:{}",
    this.processorId);
 }
 if (processor == null) {
  if (isDebugEnabled) {
   logger.debug("FetchVersionReplyMessage processor not found");
  }
  return;
 }
 processor.process(this);
 if (isDebugEnabled) {
  logger.trace(LogMarker.DM_VERBOSE, "{}  Processed  {}", processor, this);
 }
 dm.getStats().incReplyMessageTime(NanoTimer.getTime() - startTime);
}

代码示例来源:origin: blynkkk/blynk-server

private void send(String to, String subj, String body, String contentType) throws Exception {
  MimeMessage message = new MimeMessage(session);
  message.setFrom(from);
  message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
  message.setSubject(subj, "UTF-8");
  message.setContent(body, contentType);
  try (Transport transport = session.getTransport()) {
    transport.connect(host, username, password);
    transport.sendMessage(message, message.getAllRecipients());
  }
  log.debug("Mail sent to {}. Subj: {}", to, subj);
  log.trace("Mail body: {}", body);
}

代码示例来源:origin: apache/geode

void endDestroyRegion(DiskRegionView dr) {
 lock(true);
 try {
  if (regionStillCreated(dr)) {
   cmnEndDestroyRegion(dr);
   writeIFRecord(IFREC_END_DESTROY_REGION_ID, dr);
   if (logger.isDebugEnabled()) {
    logger.trace(LogMarker.PERSIST_WRITES_VERBOSE,
      "DiskInitFile IFREC_END_DESTROY_REGION_ID drId={}", dr.getId());
   }
  }
 } finally {
  unlock(true);
 }
}

代码示例来源:origin: apache/geode

/**
 * Unregisters an existing client from this server.
 *
 * @param memberId Uniquely identifies the client
 */
public void unregisterClient(ClientProxyMembershipID memberId, boolean normalShutdown) {
 if (logger.isDebugEnabled()) {
  logger.debug("CacheClientNotifier: Unregistering all clients with member id: {}", memberId);
 }
 CacheClientProxy proxy = getClientProxy(memberId);
 if (proxy != null) {
  final boolean isTraceEnabled = logger.isTraceEnabled();
  if (isTraceEnabled) {
   logger.trace("CacheClientNotifier: Potential client: {}", proxy);
  }
  // If the proxy's member id is the same as the input member id, add
  // it to the set of dead proxies.
  if (!proxy.startRemoval()) {
   if (isTraceEnabled) {
    logger.trace("CacheClientNotifier: Potential client: {} matches {}", proxy, memberId);
   }
   closeDeadProxies(Collections.singletonList(proxy), normalShutdown);
  }
 }
}

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

public static void main(final String[] args) {
  System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console-highlight-default.xml")) {
    LOG.fatal("Fatal message.");
    LOG.error("Error message.");
    LOG.warn("Warning message.");
    LOG.info("Information message.");
    LOG.debug("Debug message.");
    LOG.trace("Trace message.");
    LOG.error("Error message.", new IOException("test"));
  }
}

代码示例来源:origin: apache/geode

@Override
public void endListField(String fieldName) {
 if (logger.isTraceEnabled()) {
  logger.trace("endListField fieldName: {}", fieldName);
 }
}

代码示例来源:origin: apache/geode

@Override
protected void process(ClusterDistributionManager dm) {
 try {
  if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) {
   logger.trace(LogMarker.DM_VERBOSE, "{}: processing message {}", getClass().getName(), this);
  }
  IdentityReplyMessage.send(getSender(), getProcessorId(), dm);
 } catch (VirtualMachineError err) {
  SystemFailure.initiateFailure(err);
  // If this ever returns, rethrow the error. We're poisoned
  // now, so don't let this thread continue.
  throw err;
 } catch (Throwable t) {
  // Whenever you catch Error or Throwable, you must also
  // catch VirtualMachineError (see above). However, there is
  // _still_ a possibility that you are dealing with a cascading
  // error condition, so you also need to check to see if the JVM
  // is still usable:
  SystemFailure.checkFailure();
  logger.debug("{} Caught throwable {}", this, t.getMessage(), t);
 }
}

代码示例来源:origin: apache/geode

this.stats.incFinalCheckRequestsSent();
  this.stats.incTcpFinalCheckRequestsSent();
  logger.debug("Connected to suspect member - reading response");
  int b = in.read();
  if (logger.isDebugEnabled()) {
   logger.debug("Received {}",
     (b == OK ? "OK" : (b == ERROR ? "ERROR" : "unknown response: " + b)));
 logger.debug("Availability check TCP/IP connection timed out for suspect member {}",
   suspectMember);
 return false;
} catch (IOException e) {
 logger.trace("Unexpected exception", e);

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

@Test
  public void testFilter() {
    StructuredDataMessage msg = new StructuredDataMessage("Test", "This is a test", "Service");
    msg.put("Key1", "Value2");
    msg.put("Key2", "Value1");
    final Logger logger = LogManager.getLogger("org.apache.logging.log4j.core.Logging");
    logger.debug(msg);
    msg = new StructuredDataMessage("Test", "This is a test", "Service");
    msg.put("Key1", "Value1");
    msg.put("Key2", "Value2");
    logger.trace(msg);

    final List<LogEvent> list = app.getEvents();
    assertTrue("Events were generated", list == null || list.isEmpty());
  }
}

代码示例来源:origin: floragunncom/search-guard

if (log.isTraceEnabled()) {
  log.trace("Treat certificate with principal {} as other node because of it matches one of {}", Arrays.toString(principals),
      nodesDn);
if (log.isTraceEnabled()) {
  log.trace("Treat certificate with principal {} NOT as other node because we it does not matches one of {}", Arrays.toString(principals),
      nodesDn);
  if (log.isTraceEnabled()) {
    log.trace("No subject alternative names (san) found");
if (log.isDebugEnabled()) {
  log.debug("Exception parsing certificate using {}", e, this.getClass());

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

public static void main(final String[] args) {
  System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console-highlight.xml")) {
    LOG.fatal("Fatal message.");
    LOG.error("Error message.");
    LOG.warn("Warning message.");
    LOG.info("Information message.");
    LOG.debug("Debug message.");
    LOG.trace("Trace message.");
    LOG.error("Error message.", new IOException("test"));
  }
}

代码示例来源:origin: apache/geode

@Override
public void setPdxFieldName(String name) {
 if (logger.isTraceEnabled()) {
  logger.trace("setPdxClassName : {}", name);
 }
 m_PdxName = name;
}

代码示例来源:origin: apache/geode

/**
 * Processes this message. This method is invoked by the receiver of the message.
 *
 * @param dm the distribution manager that is processing the message.
 */
@Override
protected void process(final ClusterDistributionManager dm) {
 final long startTime = getTimestamp();
 if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) {
  logger.trace(LogMarker.DM_VERBOSE,
    "PRDistributedBucketSizeReplyMessage process invoking reply processor with processorId: {}",
    this.processorId);
 }
 ReplyProcessor21 processor = ReplyProcessor21.getProcessor(this.processorId);
 if (processor == null) {
  if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) {
   logger.debug("PRDistributedBucketSizeReplyMessage processor not found");
  }
  return;
 }
 processor.process(this);
 if (logger.isTraceEnabled(LogMarker.DM_VERBOSE)) {
  logger.trace(LogMarker.DM_VERBOSE, "{} Processed {}", processor, this);
 }
 dm.getStats().incReplyMessageTime(DistributionStats.getStatTime() - startTime);
}

代码示例来源:origin: blynkkk/blynk-server

@Override
public Response onCompleted(Response response) {
  if (isValidResponseCode(response.getStatusCode())) {
    webHook.failureCounter = 0;
    if (response.hasResponseBody()) {
      //todo could be optimized with response.getResponseBodyAsByteBuffer()
      String body = DataStream.makeHardwareBody(webHook.pinType, webHook.pin,
          response.getResponseBody(CharsetUtil.UTF_8));
      log.trace("Sending webhook to hardware. {}", body);
      session.sendMessageToHardware(dashId, Command.HARDWARE, 888, body, deviceId);
    }
  } else {
    webHook.failureCounter++;
    log.debug("Error sending webhook for {}. Code {}.", email, response.getStatusCode());
    if (log.isDebugEnabled()) {
      log.debug("Reason {}", response.getResponseBody());
    }
  }
  return null;
}

代码示例来源:origin: apache/geode

final boolean isDebugEnabled = logger.isDebugEnabled();
final boolean isTraceEnabled = logger.isTraceEnabled();
 logger.debug("CacheClientNotifier: Determining client for {}", durableClientId);
 CacheClientProxy clientProxy = (CacheClientProxy) i.next();
 if (isTraceEnabled) {
  logger.trace("CacheClientNotifier: Checking client {}", clientProxy);
   logger.debug("CacheClientNotifier: {} represents the durable client {}", proxy,
     durableClientId);
  CacheClientProxy clientProxy = (CacheClientProxy) i.next();
  if (isTraceEnabled) {
   logger.trace("CacheClientNotifier: Checking initializing client {}", clientProxy);
    logger.debug(
      "CacheClientNotifier: initializing client {} represents the durable client {}",
      proxy, durableClientId);

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

public static void main(final String[] args) {
  System.setProperty("log4j.skipJansi", "false"); // LOG4J2-2087: explicitly enable
  try (final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(),
      "target/test-classes/log4j2-console.xml")) {
    LOG.fatal("\u001b[1;35mFatal message.\u001b[0m");
    LOG.error("\u001b[1;31mError message.\u001b[0m");
    LOG.warn("\u001b[0;33mWarning message.\u001b[0m");
    LOG.info("\u001b[0;32mInformation message.\u001b[0m");
    LOG.debug("\u001b[0;36mDebug message.\u001b[0m");
    LOG.trace("\u001b[0;30mTrace message.\u001b[0m");
    LOG.error("\u001b[1;31mError message.\u001b[0m", new IOException("test"));
  }
}

相关文章