@ChannelHandler.Sharable public class LoggingHandler extends Object implements ChannelUpstreamHandler, ChannelDownstreamHandler
ChannelHandler
that logs all events via InternalLogger
.
By default, all events are logged at DEBUG level. You can extend
this class and override log(ChannelEvent)
to change the default
behavior.ChannelHandler.Sharable
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(boolean hexDump)
Creates a new instance whose logger name is the fully qualified class
name of the instance.
|
LoggingHandler(Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump
enabled.
|
LoggingHandler(Class<?> clazz,
boolean hexDump)
Creates a new instance with the specified logger name.
|
LoggingHandler(Class<?> clazz,
InternalLogLevel level)
Creates a new instance with the specified logger name.
|
LoggingHandler(Class<?> clazz,
InternalLogLevel level,
boolean hexDump)
Creates a new instance with the specified logger name.
|
LoggingHandler(InternalLogLevel level)
Creates a new instance whose logger name is the fully qualified class
name of the instance.
|
LoggingHandler(InternalLogLevel level,
boolean hexDump)
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 and with hex dump
enabled.
|
LoggingHandler(String name,
boolean hexDump)
Creates a new instance with the specified logger name.
|
LoggingHandler(String name,
InternalLogLevel level,
boolean hexDump)
Creates a new instance with the specified logger name.
|
Modifier and Type | Method and Description |
---|---|
InternalLogLevel |
getLevel()
Returns the
InternalLogLevel that this handler uses to log
a ChannelEvent . |
InternalLogger |
getLogger()
Returns the
InternalLogger that this handler uses to log
a ChannelEvent . |
void |
handleDownstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified downstream event.
|
void |
handleUpstream(ChannelHandlerContext ctx,
ChannelEvent e)
Handles the specified upstream event.
|
void |
log(ChannelEvent e)
Logs the specified event to the
InternalLogger returned by
getLogger() . |
public LoggingHandler()
public LoggingHandler(InternalLogLevel level)
level
- the log levelpublic LoggingHandler(boolean hexDump)
hexDump
- true
if and only if the hex dump of the received
message is loggedpublic LoggingHandler(InternalLogLevel level, boolean hexDump)
level
- the log levelhexDump
- true
if and only if the hex dump of the received
message is loggedpublic LoggingHandler(Class<?> clazz)
public LoggingHandler(Class<?> clazz, boolean hexDump)
hexDump
- true
if and only if the hex dump of the received
message is loggedpublic LoggingHandler(Class<?> clazz, InternalLogLevel level)
level
- the log levelpublic LoggingHandler(Class<?> clazz, InternalLogLevel level, boolean hexDump)
level
- the log levelhexDump
- true
if and only if the hex dump of the received
message is loggedpublic LoggingHandler(String name)
public LoggingHandler(String name, boolean hexDump)
hexDump
- true
if and only if the hex dump of the received
message is loggedpublic LoggingHandler(String name, InternalLogLevel level, boolean hexDump)
level
- the log levelhexDump
- true
if and only if the hex dump of the received
message is loggedpublic InternalLogger getLogger()
InternalLogger
that this handler uses to log
a ChannelEvent
.public InternalLogLevel getLevel()
InternalLogLevel
that this handler uses to log
a ChannelEvent
.public void log(ChannelEvent e)
InternalLogger
returned by
getLogger()
. If hex dump has been enabled for this handler,
the hex dump of the ChannelBuffer
in a MessageEvent
will
be logged together.public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
ChannelUpstreamHandler
handleUpstream
in interface ChannelUpstreamHandler
ctx
- the context object for this handlere
- the upstream event to process or interceptException
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
ChannelDownstreamHandler
handleDownstream
in interface ChannelDownstreamHandler
ctx
- the context object for this handlere
- the downstream event to process or interceptException
Copyright © 2008-2013 The Netty Project. All Rights Reserved.