org.jboss.netty.handler.logging

## Class LoggingHandler

- java.lang.Object
- - org.jboss.netty.handler.logging.LoggingHandler

- All Implemented Interfaces:
    ChannelDownstreamHandler, ChannelHandler, ChannelUpstreamHandler

      @ChannelHandler.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 org.jboss.netty.channel.ChannelHandler

      `ChannelHandler.Sharable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LoggingHandler()` Creates 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(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.
    `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.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `InternalLogLevel` | `getLevel()` Returns the `InternalLogLevel` that this handler uses to log a `ChannelEvent`.
    `InternalLogger` | `getLogger()` Returns the `InternalLogger` that this handler uses to log a `ChannelEvent`.
    `void` | `handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)` Handles the specified downstream event.
    `void` | `handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)` Handles the specified upstream event.
    `void` | `log(ChannelEvent e)` Logs the specified event to the `InternalLogger` returned by `getLogger()`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LoggingHandler

          public LoggingHandler()

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

    - #### LoggingHandler

          public LoggingHandler(InternalLogLevel level)

      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` - `true` if and only if the hex dump of the received message is logged

    - #### LoggingHandler

          public LoggingHandler(InternalLogLevel level,
                        boolean hexDump)

      Creates a new instance whose logger name is the fully qualified class name of the instance.
      Parameters:
        `level` - the log level
        `hexDump` - `true` if and only if the hex dump of the received message is logged

    - #### LoggingHandler

          public LoggingHandler(Class<?> clazz)

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

    - #### LoggingHandler

          public LoggingHandler(Class<?> clazz,
                        boolean hexDump)

      Creates a new instance with the specified logger name.
      Parameters:
        `hexDump` - `true` if and only if the hex dump of the received message is logged

    - #### LoggingHandler

          public LoggingHandler(Class<?> clazz,
                        InternalLogLevel level)

      Creates a new instance with the specified logger name.
      Parameters:
        `level` - the log level

    - #### LoggingHandler

          public LoggingHandler(Class<?> clazz,
                        InternalLogLevel level,
                        boolean hexDump)

      Creates a new instance with the specified logger name.
      Parameters:
        `level` - the log level
        `hexDump` - `true` if and only if the hex dump of the received message is logged

    - #### LoggingHandler

          public LoggingHandler(String name)

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

    - #### LoggingHandler

          public LoggingHandler(String name,
                        boolean hexDump)

      Creates a new instance with the specified logger name.
      Parameters:
        `hexDump` - `true` if and only if the hex dump of the received message is logged

    - #### LoggingHandler

          public LoggingHandler(String name,
                        InternalLogLevel level,
                        boolean hexDump)

      Creates a new instance with the specified logger name.
      Parameters:
        `level` - the log level
        `hexDump` - `true` if and only if the hex dump of the received message is logged

  - ### Method Detail

    - #### getLogger

          public InternalLogger getLogger()

      Returns the `InternalLogger` that this handler uses to log a `ChannelEvent`.

    - #### getLevel

          public InternalLogLevel getLevel()

      Returns the `InternalLogLevel` that this handler uses to log a `ChannelEvent`.

    - #### log

          public void log(ChannelEvent e)

      Logs the specified event to the `InternalLogger` returned by `getLogger()`. If hex dump has been enabled for this handler, the hex dump of the `ChannelBuffer` in a `MessageEvent` will be logged together.

    - #### handleUpstream

          public void handleUpstream(ChannelHandlerContext ctx,
                            ChannelEvent e)
                              throws Exception

      Description copied from interface: `ChannelUpstreamHandler`
      Handles the specified upstream event.
      Specified by:
        `handleUpstream` in interface `ChannelUpstreamHandler`
      Parameters:
        `ctx` - the context object for this handler
        `e` - the upstream event to process or intercept
      Throws:
        `Exception`

    - #### handleDownstream

          public void handleDownstream(ChannelHandlerContext ctx,
                              ChannelEvent e)
                                throws Exception

      Description copied from interface: `ChannelDownstreamHandler`
      Handles the specified downstream event.
      Specified by:
        `handleDownstream` in interface `ChannelDownstreamHandler`
      Parameters:
        `ctx` - the context object for this handler
        `e` - the downstream event to process or intercept
      Throws:
        `Exception`

Copyright © 2008-2012 The Netty Project. All Rights Reserved.