Class HttpAccessLogHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

    @Sharable
    public class HttpAccessLogHandler
    extends io.netty.channel.ChannelDuplexHandler
    Logging handler for HTTP access logs. Access logs will be logged at info level.
    Since:
    2.0
    • 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
      static java.lang.String HTTP_ACCESS_LOGGER
      The default logger name.
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpAccessLogHandler​(java.lang.String loggerName, java.lang.String spec)
      Creates a HttpAccessLogHandler.
      HttpAccessLogHandler​(java.lang.String loggerName, java.lang.String spec, java.util.function.Predicate<java.lang.String> uriInclusion)
      Creates a HttpAccessLogHandler.
      HttpAccessLogHandler​(org.slf4j.Logger logger, java.lang.String spec)
      Creates a HttpAccessLogHandler.
      HttpAccessLogHandler​(org.slf4j.Logger logger, java.lang.String spec, java.util.function.Predicate<java.lang.String> uriInclusion)
      Creates a HttpAccessLogHandler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void channelRead​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg)  
      void write​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise)  
      • Methods inherited from class io.netty.channel.ChannelDuplexHandler

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
      • 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

      • HTTP_ACCESS_LOGGER

        public static final java.lang.String HTTP_ACCESS_LOGGER
        The default logger name.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HttpAccessLogHandler

        public HttpAccessLogHandler​(java.lang.String loggerName,
                                    java.lang.String spec)
        Creates a HttpAccessLogHandler.
        Parameters:
        loggerName - A logger name.
        spec - The log format specification.
      • HttpAccessLogHandler

        public HttpAccessLogHandler​(java.lang.String loggerName,
                                    java.lang.String spec,
                                    java.util.function.Predicate<java.lang.String> uriInclusion)
        Creates a HttpAccessLogHandler.
        Parameters:
        loggerName - A logger name.
        spec - The log format specification.
        uriInclusion - A filtering Predicate that will be checked per URI.
      • HttpAccessLogHandler

        public HttpAccessLogHandler​(org.slf4j.Logger logger,
                                    java.lang.String spec)
        Creates a HttpAccessLogHandler.
        Parameters:
        logger - A logger. Will log at info level.
        spec - The log format specification.
      • HttpAccessLogHandler

        public HttpAccessLogHandler​(org.slf4j.Logger logger,
                                    java.lang.String spec,
                                    java.util.function.Predicate<java.lang.String> uriInclusion)
        Creates a HttpAccessLogHandler.
        Parameters:
        logger - A logger. Will log at info level.
        spec - The log format specification.
        uriInclusion - A filtering Predicate that will be checked per URI.
    • Method Detail

      • channelRead

        public void channelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                java.lang.Object msg)
                         throws io.netty.handler.codec.http2.Http2Exception
        Specified by:
        channelRead in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        io.netty.handler.codec.http2.Http2Exception
      • 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.channel.ChannelDuplexHandler
        Throws:
        java.lang.Exception