org.apache.log4j.spi

## Class LoggingEventFieldResolver

- java.lang.Object
- - org.apache.log4j.spi.LoggingEventFieldResolver

-     public final class LoggingEventFieldResolver
      extends Object

  A singleton helper utility which accepts a field name and a LoggingEvent and returns the value of that field. This class defines a grammar used in creation of an expression-based Rule. The only available method is Object getField(String fieldName, LoggingEvent event). Here is a description of the mapping of field names in the grammar to fields on the logging event. While the getField method returns an Object, the individual types returned per field are described here: Field Name Field value (String representation Return type LOGGER category name (logger) String LEVEL level Level CLASS locationInformation's class name String FILE locationInformation's file name String LINE locationInformation's line number String METHOD locationInformation's method name String MSG message Object NDC NDC String EXCEPTION throwable string representation ThrowableInformation TIMESTAMP timestamp Long THREAD thread String PROP.keyName entry in the Property hashtable String mapped to the key [keyName] NOTE: the values for the 'keyName' portion of the MDC and PROP mappings must be an exact match to the key in the hashTable (case sensitive). If the passed-in field is null or doesn't match an entry in the above-described mapping, an exception is thrown.
  Author:
    Scott Deboy (sdeboy@apache.org), Paul Smith (psmith@apache.org)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CLASS_FIELD` CLASS string literal.
    `static String` | `EMPTY_STRING` empty string literal.
    `static String` | `EXCEPTION_FIELD` EXCEPTION string literal.
    `static String` | `FILE_FIELD` FILE string literal.
    `static List` | `KEYWORD_LIST` Keyword list.
    `static String` | `LEVEL_FIELD` LEVEL string literal.
    `static String` | `LINE_FIELD` LINE string literal.
    `static String` | `LOGGER_FIELD` LOGGER string literal.
    `static String` | `METHOD_FIELD` METHOD string literal.
    `static String` | `MSG_FIELD` MSG string literal.
    `static String` | `NDC_FIELD` NDC string literal.
    `static String` | `PROP_FIELD` PROP. string literal.
    `static String` | `THREAD_FIELD` THREAD string literal.
    `static String` | `TIMESTAMP_FIELD` TIMESTAMP string literal.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `applyFields(String replaceText, org.apache.log4j.spi.LoggingEvent event)` Apply fields.
    `static LoggingEventFieldResolver` | `getInstance()` Get singleton instance.
    `Object` | `getValue(String fieldName, org.apache.log4j.spi.LoggingEvent event)` Get value of field.
    `boolean` | `isField(String fieldName)` Determines if specified string is a recognized field.

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

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

- - ### Field Detail

    - #### KEYWORD_LIST

          public static final List KEYWORD_LIST

      Keyword list.

    - #### LOGGER_FIELD

          public static final String LOGGER_FIELD

      LOGGER string literal.
      See Also:
        Constant Field Values

    - #### LEVEL_FIELD

          public static final String LEVEL_FIELD

      LEVEL string literal.
      See Also:
        Constant Field Values

    - #### CLASS_FIELD

          public static final String CLASS_FIELD

      CLASS string literal.
      See Also:
        Constant Field Values

    - #### FILE_FIELD

          public static final String FILE_FIELD

      FILE string literal.
      See Also:
        Constant Field Values

    - #### LINE_FIELD

          public static final String LINE_FIELD

      LINE string literal.
      See Also:
        Constant Field Values

    - #### METHOD_FIELD

          public static final String METHOD_FIELD

      METHOD string literal.
      See Also:
        Constant Field Values

    - #### MSG_FIELD

          public static final String MSG_FIELD

      MSG string literal.
      See Also:
        Constant Field Values

    - #### NDC_FIELD

          public static final String NDC_FIELD

      NDC string literal.
      See Also:
        Constant Field Values

    - #### EXCEPTION_FIELD

          public static final String EXCEPTION_FIELD

      EXCEPTION string literal.
      See Also:
        Constant Field Values

    - #### TIMESTAMP_FIELD

          public static final String TIMESTAMP_FIELD

      TIMESTAMP string literal.
      See Also:
        Constant Field Values

    - #### THREAD_FIELD

          public static final String THREAD_FIELD

      THREAD string literal.
      See Also:
        Constant Field Values

    - #### PROP_FIELD

          public static final String PROP_FIELD

      PROP. string literal.
      See Also:
        Constant Field Values

    - #### EMPTY_STRING

          public static final String EMPTY_STRING

      empty string literal.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### applyFields

          public String applyFields(String replaceText,
                           org.apache.log4j.spi.LoggingEvent event)

      Apply fields.
      Parameters:
        `replaceText` - replacement text.
        `event` - logging event.
      Returns:
        evaluted expression

    - #### getInstance

          public static LoggingEventFieldResolver getInstance()

      Get singleton instance.
      Returns:
        singleton instance

    - #### isField

          public boolean isField(String fieldName)

      Determines if specified string is a recognized field.
      Parameters:
        `fieldName` - field name
      Returns:
        true if recognized field.

    - #### getValue

          public Object getValue(String fieldName,
                        org.apache.log4j.spi.LoggingEvent event)

      Get value of field.
      Parameters:
        `fieldName` - field
        `event` - event
      Returns:
        value of field

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.