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
A
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]private static final String[]private static final String[]private static final InternalLogLevelprivate final booleanprivate static final String[]private final InternalLogLevelprivate final InternalLoggerprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionCreates 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
Modifier and TypeMethodDescriptionprivate static StringgetLevel()Returns theInternalLogLevelthat this handler uses to log aChannelEvent.Returns theInternalLoggerthat this handler uses to log aChannelEvent.voidHandles the specified downstream event.voidHandles the specified upstream event.voidlog(ChannelEvent e) Logs the specified event to theInternalLoggerreturned bygetLogger().
-
Field Details
-
DEFAULT_LEVEL
-
NEWLINE
-
BYTE2HEX
-
HEXPADDING
-
BYTEPADDING
-
BYTE2CHAR
private static final char[] BYTE2CHAR -
logger
-
level
-
hexDump
private final boolean hexDump
-
-
Constructor Details
-
LoggingHandler
public LoggingHandler()Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled. -
LoggingHandler
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
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
Creates a new instance with the specified logger name and with hex dump enabled. -
LoggingHandler
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
Creates a new instance with the specified logger name.- Parameters:
level- the log level
-
LoggingHandler
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
Creates a new instance with the specified logger name and with hex dump enabled. -
LoggingHandler
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
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 Details
-
getLogger
Returns theInternalLoggerthat this handler uses to log aChannelEvent. -
getLevel
Returns theInternalLogLevelthat this handler uses to log aChannelEvent. -
log
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. -
formatBuffer
-
handleUpstream
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
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
-