@ChannelHandler.Sharable
public class LoggingHandler
extends io.netty.channel.ChannelDuplexHandler
ChannelHandler that logs all events using a logging framework.
By default, all events are logged at DEBUG level.| Modifier and Type | Field and Description |
|---|---|
protected io.netty.util.internal.logging.InternalLogLevel |
internalLevel |
protected io.netty.util.internal.logging.InternalLogger |
logger |
| Constructor and Description |
|---|
LoggingHandler()
Creates a new instance whose logger name is the fully qualified class
name of the instance with hex dump enabled.
|
LoggingHandler(Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump
enabled.
|
LoggingHandler(Class<?> clazz,
LogLevel level)
Creates a new instance with the specified logger name.
|
LoggingHandler(LogLevel level)
Creates a new instance whose logger name is the fully qualified class
name of the instance.
|
LoggingHandler(String name)
Creates a new instance with the specified logger name.
|
LoggingHandler(String name,
LogLevel level)
Creates a new instance with the specified logger name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bind(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
channelRegistered(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelUnregistered(io.netty.channel.ChannelHandlerContext ctx) |
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise) |
void |
deregister(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
disconnect(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
void |
flush(io.netty.channel.ChannelHandlerContext ctx) |
protected String |
format(io.netty.channel.ChannelHandlerContext ctx,
String message) |
protected String |
formatByteBuf(String eventName,
io.netty.buffer.ByteBuf msg)
Returns a String which contains all details to log the
ByteBuf |
protected String |
formatByteBufHolder(String eventName,
io.netty.buffer.ByteBufHolder msg)
Returns a String which contains all details to log the
ByteBufHolder. |
protected String |
formatMessage(String eventName,
Object msg) |
protected String |
formatNonByteBuf(String eventName,
Object msg)
Returns a String which contains all details to log the
Object |
LogLevel |
level()
Returns the
LogLevel that this handler uses to log |
void |
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt) |
void |
write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise) |
channelReadComplete, channelWritabilityChangedhandlerAdded, handlerRemoved, isSharableprotected final io.netty.util.internal.logging.InternalLogger logger
protected final io.netty.util.internal.logging.InternalLogLevel internalLevel
public LoggingHandler()
public LoggingHandler(LogLevel level)
level - the log levelpublic LoggingHandler(Class<?> clazz)
public LoggingHandler(Class<?> clazz, LogLevel level)
level - the log levelpublic LoggingHandler(String name)
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelRegistered in interface io.netty.channel.ChannelInboundHandlerchannelRegistered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelUnregistered(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelUnregistered in interface io.netty.channel.ChannelInboundHandlerchannelUnregistered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelActive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelActive in interface io.netty.channel.ChannelInboundHandlerchannelActive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
channelInactive in interface io.netty.channel.ChannelInboundHandlerchannelInactive in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause)
throws Exception
exceptionCaught in interface io.netty.channel.ChannelHandlerexceptionCaught in interface io.netty.channel.ChannelInboundHandlerexceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx,
Object evt)
throws Exception
userEventTriggered in interface io.netty.channel.ChannelInboundHandleruserEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void bind(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
bind in interface io.netty.channel.ChannelOutboundHandlerbind in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void connect(io.netty.channel.ChannelHandlerContext ctx,
SocketAddress remoteAddress,
SocketAddress localAddress,
io.netty.channel.ChannelPromise promise)
throws Exception
connect in interface io.netty.channel.ChannelOutboundHandlerconnect in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void disconnect(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
disconnect in interface io.netty.channel.ChannelOutboundHandlerdisconnect in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
close in interface io.netty.channel.ChannelOutboundHandlerclose in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void deregister(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise)
throws Exception
deregister in interface io.netty.channel.ChannelOutboundHandlerderegister in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg)
throws Exception
channelRead in interface io.netty.channel.ChannelInboundHandlerchannelRead in class io.netty.channel.ChannelInboundHandlerAdapterExceptionpublic void write(io.netty.channel.ChannelHandlerContext ctx,
Object msg,
io.netty.channel.ChannelPromise promise)
throws Exception
write in interface io.netty.channel.ChannelOutboundHandlerwrite in class io.netty.channel.ChannelDuplexHandlerExceptionpublic void flush(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
flush in interface io.netty.channel.ChannelOutboundHandlerflush in class io.netty.channel.ChannelDuplexHandlerExceptionprotected String formatByteBuf(String eventName, io.netty.buffer.ByteBuf msg)
ByteBufprotected String formatNonByteBuf(String eventName, Object msg)
Objectprotected String formatByteBufHolder(String eventName, io.netty.buffer.ByteBufHolder msg)
ByteBufHolder.
By default this method just delegates to formatByteBuf(String, ByteBuf),
using the content of the ByteBufHolder. Sub-classes may override this.Copyright © 2008–2016 The Netty Project. All rights reserved.