org.slf4j.Logger.isTraceEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(347)

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

Logger.isTraceEnabled介绍

[英]Is the logger instance enabled for the TRACE level?
[中]是否为跟踪级别启用了记录器实例?

代码示例

代码示例来源:origin: spring-projects/spring-framework

public void trace(Object message) {
  if (message instanceof String || this.logger.isTraceEnabled()) {
    this.logger.trace(String.valueOf(message));
  }
}

代码示例来源:origin: Graylog2/graylog2-server

@Override
  protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
    if (sourceInputLog.isTraceEnabled()) {
      sourceInputLog.trace("Recv network data: {} bytes via input '{}' <{}> from remote address {}",
          msg.readableBytes(), sourceInputName, sourceInputId, ctx.channel().remoteAddress());
    }
  }
}

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

public void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws IOException {
  logger.trace("Channel closed before decoding the message of {} bytes", msg.readableBytes());
  msg.skipBytes(msg.readableBytes());
  return;
  if(logger.isTraceEnabled()) {
   logger.trace("Trying to decrypt the encrypted message of size: {} with maxWrappedSize", msg.readableBytes());
  msg.getBytes(msg.readerIndex(), lengthOctets.array(), 0, RpcConstants.LENGTH_FIELD_LENGTH);
  final int wrappedMsgLength = lengthOctets.getInt(0);
  msg.skipBytes(RpcConstants.LENGTH_FIELD_LENGTH);
  msg.getBytes(msg.readerIndex(), wrappedMsg, 0, wrappedMsgLength);
  if(logger.isTraceEnabled()) {
   logger.trace("Successfully decrypted incoming message. Length after decryption: {}", decodedMsg.length);

代码示例来源:origin: org.opendaylight.controller/netconf-netty-util

@Override
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws IOException, SAXException {
  if (in.isReadable()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
      if (!isWhitespace(in.readByte())) {
        in.readerIndex(in.readerIndex() - 1);
        break;
    if (in.readerIndex() != 0 && LOG.isWarnEnabled()) {
      final byte[] strippedBytes = new byte[in.readerIndex()];
      in.getBytes(0, strippedBytes, 0, in.readerIndex());

代码示例来源:origin: org.apache.plc4x/plc4j-protocol-s7

protected void decode(ChannelHandlerContext ctx, IsoTPMessage in, List<Object> out) {
  if (logger.isTraceEnabled()) {
    logger.trace("Got Data: {}", ByteBufUtil.hexDump(in.getUserData()));
  if (userData.readableBytes() == 0) {
    return;
  userData.readShort();  // Reserved (is always constant 0x0000)
  short tpduReference = userData.readShort();
  short headerParametersLength = userData.readShort();
  short userDataLength = userData.readShort();
  byte errorClass = 0;

代码示例来源:origin: org.apache.distributedlog/distributedlog-protocol

if (LOG.isTraceEnabled()) {
    LOG.trace("Found position {} beyond {}", recordStream.getCurrentPosition(), dlsn);
    if (LOG.isTraceEnabled()) {
      LOG.trace("Found position {} beyond {}", currTxId, txId);
  recordSetReader = LogRecordSet.of(record);
} else {
  int length = in.readInt();
  if (length < 0) {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Skipped Record with TxId {} DLSN {}",
      currTxId, recordStream.getCurrentPosition());

代码示例来源:origin: spring-projects/spring-framework

public void trace(Object message, Throwable exception) {
  if (message instanceof String || this.logger.isTraceEnabled()) {
    this.logger.trace(String.valueOf(message), exception);
  }
}

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

if (LOG.isTraceEnabled()) {
  LOG.trace("0x{} buf {}",
      Long.toHexString(sessionId),
      ByteBufUtil.hexDump(buf));
    queuedBuffer = channel.alloc().buffer(buf.readableBytes());
  if (LOG.isTraceEnabled()) {
    LOG.trace("0x{} queuedBuffer {}",
        Long.toHexString(sessionId),
        ByteBufUtil.hexDump(queuedBuffer));
      if (LOG.isTraceEnabled()) {
        LOG.trace("Before copy {}", buf);
        queuedBuffer = channel.alloc().buffer(buf.readableBytes());
      if (LOG.isTraceEnabled()) {
        LOG.trace("Copy is {}", queuedBuffer);
        LOG.trace("0x{} queuedBuffer {}",

代码示例来源:origin: org.opendaylight.netconf/netconf-netty-util

@Override
public void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws IOException, SAXException {
  if (in.isReadable()) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
      if (!isWhitespace(in.readByte())) {
        in.readerIndex(in.readerIndex() - 1);
        break;
    if (in.readerIndex() != 0 && LOG.isWarnEnabled()) {
      final byte[] strippedBytes = new byte[in.readerIndex()];
      in.getBytes(0, strippedBytes, 0, in.readerIndex());

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

if (component.readableBytes() > wrapSizeLimit) {
 throw new RpcException(String.format("Component Chunk size: %d is greater than the wrapSizeLimit: %d",
   component.readableBytes(), wrapSizeLimit));
component.getBytes(component.readerIndex(), origMsg, 0, component.readableBytes());
if(logger.isTraceEnabled()) {
 logger.trace("Trying to encrypt chunk of size:{} with wrapSizeLimit:{} and chunkMode: {}",
   component.readableBytes(), wrapSizeLimit);
final byte[] wrappedMsg = saslCodec.wrap(origMsg, 0, component.readableBytes());
if(logger.isTraceEnabled()) {
 logger.trace("Successfully encrypted message, original size: {} Final Size: {}",
   component.readableBytes(), wrappedMsg.length);

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

synchronized public void setSessionClosing(long sessionId) {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Session closing: 0x" + Long.toHexString(sessionId));
  }
  SessionImpl s = sessionsById.get(sessionId);
  if (s == null) {
    return;
  }
  s.isClosing = true;
}

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

while(message.isReadable() && !throttled.get()) {
  if (bb != null) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("message readable {} bb len {} {}",
          message.readableBytes(),
          bb.remaining(),
          bb);
      ByteBuffer dat = bb.duplicate();
      dat.flip();
      LOG.trace("0x{} bb {}",
          Long.toHexString(sessionId),
          ByteBufUtil.hexDump(Unpooled.wrappedBuffer(dat)));
    if (LOG.isTraceEnabled()) {
      LOG.trace("after readBytes message readable {} bb len {} {}",
          message.readableBytes(),
          bb.remaining(),
    if (LOG.isTraceEnabled()) {
      LOG.trace("message readable {} bblenrem {}",
          message.readableBytes(),
      if (LOG.isTraceEnabled()) {
        LOG.trace("0x{} bbLen {}",
            Long.toHexString(sessionId),
      if (LOG.isTraceEnabled()) {
        LOG.trace("0x{} bbLen len is {}",
            Long.toHexString(sessionId),

代码示例来源:origin: waterguo/antsdb

@Override
public void read(MysqlClientHandler handler, ByteBuf in) {
  int begin = in.readerIndex();
  int index = in.readerIndex();
  colCount = (int)BufferUtils.readLength(in);
  int readCnt = in.readerIndex() - index;
  int end = in.readerIndex();
  if (_log.isTraceEnabled())
    in.readerIndex(begin);
    in.readBytes(bytes);
    String dump = '\n' + UberUtil.hexDump(bytes);
    _log.trace("Packet Info:\n"
        + this.toString()
        + "\nRowsEventV2Packet packet:\n"

代码示例来源:origin: com.orange.redis-protocol/netty4

/**
 * Create a frame out of the {@link ByteBuf} and return it.
 * 
 * @param ctx
 *          the {@link ChannelHandlerContext} which this {@link ByteToMessageDecoder} belongs to
 * @param in
 *          the {@link ByteBuf} from which to read data
 * @return frame the {@link ByteBuf} which represent the frame or {@code null} if no frame could be created.
 */
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
 if (LOG.isDebugEnabled()) {
  int readableBytes = in.readableBytes();
  // int readableBytes = 1;
  LOG.trace("readableBytes={}", readableBytes);
  byte[] dst = new byte[readableBytes];
  in.getBytes(in.readerIndex(), dst, 0, readableBytes);
  if (LOG.isTraceEnabled()) {
   LOG.trace("*decoder received : {}", new String(dst, CharsetUtil.UTF_8).replaceAll("\r\n", " "));
  }
 }
 return receive(in);
}

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

@Override
void close() {
  try {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Doing client selector close");
    }
    selector.close();
    if (LOG.isTraceEnabled()) {
      LOG.trace("Closed client selector");
    }
  } catch (IOException e) {
    LOG.warn("Ignoring exception during selector close", e);
  }
}

代码示例来源:origin: micronaut-projects/micronaut-core

if (content.refCnt() == 0 || content.readableBytes() == 0) {
  if (LOG.isTraceEnabled()) {
    LOG.trace("Full HTTP response received an empty body");
} else if (!hasContentType && LOG.isTraceEnabled()) {
  LOG.trace("Missing or unknown Content-Type received from server.");

代码示例来源:origin: waterguo/antsdb

@Override
public void read(MysqlClientHandler handler, ByteBuf in) {
  int begin = in.readerIndex();
  in.readBytes(nullBitMap);
  int end = in.readerIndex();
  if (_log.isTraceEnabled())
    in.readerIndex(begin);
    byte[] bytes = new byte[end - begin];
    in.readBytes(bytes);
    String dump = '\n' + UberUtil.hexDump(bytes);
    _log.trace("Packet Info:\n"
        + this.toString()
        + "\nTableMapPacket packet:\n"

代码示例来源:origin: Graylog2/graylog2-server

@Override
public URL getResource(String name) {
  URL url = null;
  for (ClassLoader classLoader : classLoaders) {
    url = classLoader.getResource(name);
    if (url != null) {
      break;
    }
  }
  if (url == null && LOG.isTraceEnabled()) {
    LOG.trace("Resource " + name + " not found.");
  }
  return url;
}

代码示例来源:origin: Graylog2/graylog2-server

@Nonnull
@Override
public Result addChunk(ByteBuf buf, SocketAddress remoteAddress) {
  if (buf.readableBytes() < 2) {
    if (LOG.isTraceEnabled()) {
      LOG.trace("Received V9 packet:\n{}", ByteBufUtil.prettyHexDump(buf));
    LOG.trace("Incoming NetFlow V9 packet contains: {}", rawNetFlowV9Packet);

代码示例来源:origin: Graylog2/graylog2-server

@Override
public InputStream getResourceAsStream(String name) {
  InputStream stream = null;
  for (ClassLoader classLoader : classLoaders) {
    stream = classLoader.getResourceAsStream(name);
    if (stream != null) {
      break;
    }
  }
  if (stream == null && LOG.isTraceEnabled()) {
    LOG.trace("Resource " + name + " not found.");
  }
  return stream;
}

相关文章