Top Description Fields Constructors Methods
io.netty.handler.logging

public Class LoggingHandler

extends ChannelDuplexHandler
Class Inheritance
Annotations
@Sharable
@SuppressWarnings:StringConcatenationInsideStringBufferAppend, StringBufferReplaceableByString
Imports
io.netty.buffer.ByteBuf, .ByteBufHolder, io.netty.channel.ChannelDuplexHandler, .ChannelHandler, .ChannelHandler.Sharable, .ChannelHandlerContext, .ChannelOutboundHandler, .ChannelPromise, io.netty.util.internal.ObjectUtil, io.netty.util.internal.logging.InternalLogLevel, .InternalLogger, .InternalLoggerFactory, java.net.SocketAddress

A ChannelHandler that logs all events using a logging framework. By default, all events are logged at DEBUG level and full hex dumps are recorded for ByteBufs.

Field Summary

Modifier and TypeField and Description
private final ByteBufFormat
private static final LogLevel
protected final InternalLogLevel
private final LogLevel
protected final InternalLogger

Constructor Summary

AccessConstructor and Description
public
LoggingHandler()

Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.

public
LoggingHandler(ByteBufFormat
Format of ByteBuf dumping
format
)

Creates a new instance whose logger name is the fully qualified class name of the instance.

public
LoggingHandler(LogLevel
the log level
level
)

Creates a new instance whose logger name is the fully qualified class name of the instance.

public
LoggingHandler(LogLevel
the log level
level
,
ByteBufFormat
the ByteBuf format
byteBufFormat
)

Creates a new instance whose logger name is the fully qualified class name of the instance.

public
LoggingHandler(Class<?>
the class type to generate the logger for
clazz
)

Creates a new instance with the specified logger name and with hex dump enabled.

public
LoggingHandler(Class<?>
the class type to generate the logger for
clazz
,
LogLevel
the log level
level
)

Creates a new instance with the specified logger name.

public
LoggingHandler(Class<?>
the class type to generate the logger for
clazz
,
LogLevel
the log level
level
,
ByteBufFormat
the ByteBuf format
byteBufFormat
)

Creates a new instance with the specified logger name.

public
LoggingHandler(String
the name of the class to use for the logger
name
)

Creates a new instance with the specified logger name using the default log level.

public
LoggingHandler(String
the name of the class to use for the logger
name
,
LogLevel
the log level
level
)

Creates a new instance with the specified logger name.

public
LoggingHandler(String
the name of the class to use for the logger
name
,
LogLevel
the log level
level
,
ByteBufFormat
the ByteBuf format
byteBufFormat
)

Creates a new instance with the specified logger name.

Method Summary

Modifier and TypeMethod and Description
public void
bind(ChannelHandlerContext
the ChannelHandlerContext for which the bind operation is made
ctx
,
SocketAddress
the SocketAddress to which it should bound
localAddress
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelDuplexHandler.bind.

Implements io.netty.channel.ChannelOutboundHandler.bind.

Calls ChannelHandlerContext#bind(SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
public ByteBufFormat
byteBufFormat()

Returns the ByteBufFormat that this handler uses to log

public void
public void
public void
public void
public void
public void
public void
public void
close(ChannelHandlerContext
the ChannelHandlerContext for which the close operation is made
ctx
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelDuplexHandler.close.

Implements io.netty.channel.ChannelOutboundHandler.close.

Calls ChannelHandlerContext#close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
public void
connect(ChannelHandlerContext
the ChannelHandlerContext for which the connect operation is made
ctx
,
SocketAddress
the SocketAddress to which it should connect
remoteAddress
,
SocketAddress
the SocketAddress which is used as source on connect
localAddress
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelDuplexHandler.connect.

Implements io.netty.channel.ChannelOutboundHandler.connect.

Calls ChannelHandlerContext#connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
public void
public void
public void
public void
protected String
format(ChannelHandlerContext ctx, String
the name of the event
eventName
)

Formats an event and returns the formatted message.

protected String
format(ChannelHandlerContext ctx, String
the name of the event
eventName
,
Object
the argument of the event
arg
)

Formats an event and returns the formatted message.

protected String
format(ChannelHandlerContext ctx, String
the name of the event
eventName
,
Object
the first argument of the event
firstArg
,
Object
the second argument of the event
secondArg
)

Formats an event and returns the formatted message.

private String
formatByteBuf(ChannelHandlerContext ctx, String eventName, ByteBuf msg)

Generates the default log message of the specified event whose argument is a ByteBuf.

private String
formatByteBufHolder(ChannelHandlerContext ctx, String eventName, ByteBufHolder msg)

Generates the default log message of the specified event whose argument is a ByteBufHolder.

private static String
formatSimple(ChannelHandlerContext ctx, String eventName, Object msg)

Generates the default log message of the specified event whose argument is an arbitrary object.

public LogLevel
level()

Returns the LogLevel that this handler uses to log

public void
public void
write(ChannelHandlerContext
the ChannelHandlerContext for which the write operation is made
ctx
,
Object
the message to write
msg
,
ChannelPromise
the ChannelPromise to notify once the operation completes
promise
)

Overrides io.netty.channel.ChannelDuplexHandler.write.

Implements io.netty.channel.ChannelOutboundHandler.write.

Calls ChannelHandlerContext#write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
Inherited from io.netty.channel.ChannelDuplexHandler:
read