Class Log4J2LoggingHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.ChannelDuplexHandler
-
- io.netty.handler.logging.LoggingHandler
-
- com.linkedin.alpini.netty4.handlers.Log4J2LoggingHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
public class Log4J2LoggingHandler extends io.netty.handler.logging.LoggingHandler
Created by acurtis on 4/20/18.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.logging.log4j.Level
internalLevel
protected org.apache.logging.log4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description Log4J2LoggingHandler()
Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.Log4J2LoggingHandler(io.netty.handler.logging.LogLevel level)
Creates a new instance whose logger name is the fully qualified class name of the instance.Log4J2LoggingHandler(java.lang.Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump enabled.Log4J2LoggingHandler(java.lang.Class<?> clazz, io.netty.handler.logging.LogLevel level)
Creates a new instance with the specified logger name.Log4J2LoggingHandler(java.lang.String name)
Creates a new instance with the specified logger name using the default log level.Log4J2LoggingHandler(java.lang.String name, io.netty.handler.logging.LogLevel level)
Creates a new instance with the specified logger name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise)
void
channelActive(io.netty.channel.ChannelHandlerContext ctx)
void
channelInactive(io.netty.channel.ChannelHandlerContext ctx)
void
channelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)
void
channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
void
channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
void
channelUnregistered(io.netty.channel.ChannelHandlerContext ctx)
void
channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
void
close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
void
connect(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise)
void
deregister(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
void
disconnect(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
void
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)
void
flush(io.netty.channel.ChannelHandlerContext ctx)
void
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)
void
write(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise)
-
Methods inherited from class io.netty.handler.logging.LoggingHandler
byteBufFormat, format, format, format, level
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
Log4J2LoggingHandler
public Log4J2LoggingHandler()
Creates a new instance whose logger name is the fully qualified class name of the instance with hex dump enabled.
-
Log4J2LoggingHandler
public Log4J2LoggingHandler(io.netty.handler.logging.LogLevel level)
Creates a new instance whose logger name is the fully qualified class name of the instance.- Parameters:
level
- the log level
-
Log4J2LoggingHandler
public Log4J2LoggingHandler(java.lang.Class<?> clazz)
Creates a new instance with the specified logger name and with hex dump enabled.- Parameters:
clazz
- the class type to generate the logger for
-
Log4J2LoggingHandler
public Log4J2LoggingHandler(java.lang.Class<?> clazz, io.netty.handler.logging.LogLevel level)
Creates a new instance with the specified logger name.- Parameters:
clazz
- the class type to generate the logger forlevel
- the log level
-
Log4J2LoggingHandler
public Log4J2LoggingHandler(java.lang.String name)
Creates a new instance with the specified logger name using the default log level.- Parameters:
name
- the name of the class to use for the logger
-
Log4J2LoggingHandler
public Log4J2LoggingHandler(java.lang.String name, io.netty.handler.logging.LogLevel level)
Creates a new instance with the specified logger name.- Parameters:
name
- the name of the class to use for the loggerlevel
- the log level
-
-
Method Detail
-
channelRegistered
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelRegistered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRegistered
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelUnregistered
public void channelUnregistered(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelUnregistered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelUnregistered
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt) throws java.lang.Exception
- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
bind
public void bind(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
bind
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
bind
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
connect
public void connect(io.netty.channel.ChannelHandlerContext ctx, java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
connect
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
connect
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
disconnect
public void disconnect(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
disconnect
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
disconnect
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
close
public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
close
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
close
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
deregister
public void deregister(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
deregister
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
deregister
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelReadComplete
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelReadComplete
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelReadComplete
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg) throws java.lang.Exception
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise) throws java.lang.Exception
- Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
channelWritabilityChanged
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelWritabilityChanged
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
flush
public void flush(io.netty.channel.ChannelHandlerContext ctx) throws java.lang.Exception
- Specified by:
flush
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
flush
in classio.netty.handler.logging.LoggingHandler
- Throws:
java.lang.Exception
-
-