@ChannelHandler.Sharable public class LoggingHandler extends ChannelHandlerAdapter
ChannelHandler
that logs all events using a logging framework.
By default, all events are logged at DEBUG level.ChannelHandler.Sharable, ChannelHandler.Skip
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 using the default log level.
|
LoggingHandler(String name,
LogLevel level)
Creates a new instance with the specified logger name.
|
channelReadComplete, channelWritabilityChanged, handlerAdded, handlerRemoved, isSharable, read
protected 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)
clazz
- the class type to generate the logger forpublic LoggingHandler(Class<?> clazz, LogLevel level)
clazz
- the class type to generate the logger forlevel
- the log levelpublic LoggingHandler(String name)
name
- the name of the class to use for the loggerpublic void channelRegistered(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireChannelRegistered()
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRegistered
in interface ChannelHandler
channelRegistered
in class ChannelHandlerAdapter
Exception
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireChannelUnregistered()
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelUnregistered
in interface ChannelHandler
channelUnregistered
in class ChannelHandlerAdapter
Exception
public void channelActive(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireChannelActive()
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelActive
in interface ChannelHandler
channelActive
in class ChannelHandlerAdapter
Exception
public void channelInactive(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireChannelInactive()
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelInactive
in interface ChannelHandler
channelInactive
in class ChannelHandlerAdapter
Exception
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
in interface ChannelHandler
exceptionCaught
in class ChannelHandlerAdapter
Exception
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireUserEventTriggered(Object)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.userEventTriggered
in interface ChannelHandler
userEventTriggered
in class ChannelHandlerAdapter
Exception
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.bind(java.net.SocketAddress, ChannelPromise)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.bind
in interface ChannelHandler
bind
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the bind operation is madelocalAddress
- the SocketAddress
to which it should boundpromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.connect(SocketAddress, SocketAddress, ChannelPromise)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.connect
in interface ChannelHandler
connect
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the connect operation is maderemoteAddress
- the SocketAddress
to which it should connectlocalAddress
- the SocketAddress
which is used as source on connectpromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.disconnect(ChannelPromise)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.disconnect
in interface ChannelHandler
disconnect
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the disconnect operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.close(ChannelPromise)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.close
in interface ChannelHandler
close
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.deregister(ChannelPromise)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.deregister
in interface ChannelHandler
deregister
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the close operation is madepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.fireChannelRead(Object)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelRead
in interface ChannelHandler
channelRead
in class ChannelHandlerAdapter
Exception
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.write(Object)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.write
in interface ChannelHandler
write
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the write operation is mademsg
- the message to writepromise
- the ChannelPromise
to notify once the operation completesException
- thrown if an error accourpublic void flush(ChannelHandlerContext ctx) throws Exception
ChannelHandlerAdapter
ChannelHandlerContext.flush()
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.flush
in interface ChannelHandler
flush
in class ChannelHandlerAdapter
ctx
- the ChannelHandlerContext
for which the flush operation is madeException
- thrown if an error accourprotected String format(ChannelHandlerContext ctx, String eventName)
eventName
- the name of the eventprotected String format(ChannelHandlerContext ctx, String eventName, Object arg)
eventName
- the name of the eventarg
- the argument of the eventprotected String format(ChannelHandlerContext ctx, String eventName, Object firstArg, Object secondArg)
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
.eventName
- the name of the eventfirstArg
- the first argument of the eventsecondArg
- the second argument of the eventprotected static void appendHexDump(StringBuilder dump, ByteBuf buf)
ByteBuf
to the specified
StringBuilder
.Copyright © 2008–2015 The Netty Project. All rights reserved.