Package org.jboss.netty.handler.logging
Class LoggingHandler
- java.lang.Object
-
- org.jboss.netty.handler.logging.LoggingHandler
-
- All Implemented Interfaces:
ChannelDownstreamHandler
,ChannelHandler
,ChannelUpstreamHandler
@Sharable public class LoggingHandler extends Object implements ChannelUpstreamHandler, ChannelDownstreamHandler
AChannelHandler
that logs all events viaInternalLogger
. By default, all events are logged at DEBUG level. You can extend this class and overridelog(ChannelEvent)
to change the default behavior.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Constructor Summary
Constructors Constructor 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(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.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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InternalLogLevel
getLevel()
Returns theInternalLogLevel
that this handler uses to log aChannelEvent
.InternalLogger
getLogger()
Returns theInternalLogger
that this handler uses to log aChannelEvent
.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 theInternalLogger
returned bygetLogger()
.
-
-
-
Constructor Detail
-
LoggingHandler
public LoggingHandler()
Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.
-
LoggingHandler
public LoggingHandler(InternalLogLevel level)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log level
-
LoggingHandler
public LoggingHandler(boolean hexDump)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
public LoggingHandler(InternalLogLevel level, boolean hexDump)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
public LoggingHandler(Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump enabled.
-
LoggingHandler
public LoggingHandler(Class<?> clazz, boolean hexDump)
Creates a new instance with the specified logger name.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
public LoggingHandler(Class<?> clazz, InternalLogLevel level)
Creates a new instance with the specified logger name.- Parameters:
level
- the log level
-
LoggingHandler
public LoggingHandler(Class<?> clazz, InternalLogLevel level, boolean hexDump)
Creates a new instance with the specified logger name.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
public LoggingHandler(String name)
Creates a new instance with the specified logger name and with hex dump enabled.
-
LoggingHandler
public LoggingHandler(String name, boolean hexDump)
Creates a new instance with the specified logger name.- Parameters:
hexDump
-true
if and only if the hex dump of the received message is logged
-
LoggingHandler
public LoggingHandler(String name, InternalLogLevel level, boolean hexDump)
Creates a new instance with the specified logger name.- Parameters:
level
- the log levelhexDump
-true
if and only if the hex dump of the received message is logged
-
-
Method Detail
-
getLogger
public InternalLogger getLogger()
Returns theInternalLogger
that this handler uses to log aChannelEvent
.
-
getLevel
public InternalLogLevel getLevel()
Returns theInternalLogLevel
that this handler uses to log aChannelEvent
.
-
log
public void log(ChannelEvent e)
Logs the specified event to theInternalLogger
returned bygetLogger()
. If hex dump has been enabled for this handler, the hex dump of theChannelBuffer
in aMessageEvent
will be logged together.
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
Description copied from interface:ChannelUpstreamHandler
Handles the specified upstream event.- Specified by:
handleUpstream
in interfaceChannelUpstreamHandler
- Parameters:
ctx
- the context object for this handlere
- the upstream event to process or intercept- Throws:
Exception
-
handleDownstream
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
Description copied from interface:ChannelDownstreamHandler
Handles the specified downstream event.- Specified by:
handleDownstream
in interfaceChannelDownstreamHandler
- Parameters:
ctx
- the context object for this handlere
- the downstream event to process or intercept- Throws:
Exception
-
-