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
AChannelHandlerthat 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 InternalLogLevelgetLevel()Returns theInternalLogLevelthat this handler uses to log aChannelEvent.InternalLoggergetLogger()Returns theInternalLoggerthat this handler uses to log aChannelEvent.voidhandleDownstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified downstream event.voidhandleUpstream(ChannelHandlerContext ctx, ChannelEvent e)Handles the specified upstream event.voidlog(ChannelEvent e)Logs the specified event to theInternalLoggerreturned 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-trueif 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-trueif 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-trueif 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-trueif 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-trueif 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-trueif and only if the hex dump of the received message is logged
-
-
Method Detail
-
getLogger
public InternalLogger getLogger()
Returns theInternalLoggerthat this handler uses to log aChannelEvent.
-
getLevel
public InternalLogLevel getLevel()
Returns theInternalLogLevelthat this handler uses to log aChannelEvent.
-
log
public void log(ChannelEvent e)
Logs the specified event to theInternalLoggerreturned bygetLogger(). If hex dump has been enabled for this handler, the hex dump of theChannelBufferin aMessageEventwill be logged together.
-
handleUpstream
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception
Description copied from interface:ChannelUpstreamHandlerHandles the specified upstream event.- Specified by:
handleUpstreamin 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:ChannelDownstreamHandlerHandles the specified downstream event.- Specified by:
handleDownstreamin interfaceChannelDownstreamHandler- Parameters:
ctx- the context object for this handlere- the downstream event to process or intercept- Throws:
Exception
-
-