Class 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.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • 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.ChannelDuplexHandler

        read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.netty.channel.ChannelHandler

        handlerAdded, handlerRemoved
    • Field Detail

      • logger

        protected final org.apache.logging.log4j.Logger logger
      • internalLevel

        protected final org.apache.logging.log4j.Level internalLevel
    • 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 for
        level - 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 logger
        level - the log level
    • Method Detail

      • channelRegistered

        public void channelRegistered​(io.netty.channel.ChannelHandlerContext ctx)
                               throws java.lang.Exception
        Specified by:
        channelRegistered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRegistered in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelUnregistered in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelActive in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelInactive in class io.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 interface io.netty.channel.ChannelHandler
        Specified by:
        exceptionCaught in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        exceptionCaught in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        bind in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        connect in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        disconnect in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        close in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        deregister in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelReadComplete in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        write in class io.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 interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelWritabilityChanged in class io.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 interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        flush in class io.netty.handler.logging.LoggingHandler
        Throws:
        java.lang.Exception