Package org.apache.log4j.spi
Class LoggingEventFieldResolver
java.lang.Object
org.apache.log4j.spi.LoggingEventFieldResolver
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
CLASS string literal.static final String
empty string literal.static final String
EXCEPTION string literal.static final String
FILE string literal.static final List
Keyword list.static final String
LEVEL string literal.static final String
LINE string literal.static final String
LOGGER string literal.static final String
METHOD string literal.static final String
MSG string literal.static final String
NDC string literal.static final String
PROP.private static final LoggingEventFieldResolver
LOGGER string literal.static final String
THREAD string literal.static final String
TIMESTAMP string literal. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyFields
(String replaceText, org.apache.log4j.spi.LoggingEvent event) Apply fields.private static String
getExceptionMessage
(String[] exception) Get message from throwable representation.static LoggingEventFieldResolver
Get singleton instance.Get value of field.boolean
Determines if specified string is a recognized field.
-
Field Details
-
KEYWORD_LIST
Keyword list. -
LOGGER_FIELD
LOGGER string literal.- See Also:
-
LEVEL_FIELD
LEVEL string literal.- See Also:
-
CLASS_FIELD
CLASS string literal.- See Also:
-
FILE_FIELD
FILE string literal.- See Also:
-
LINE_FIELD
LINE string literal.- See Also:
-
METHOD_FIELD
METHOD string literal.- See Also:
-
MSG_FIELD
MSG string literal.- See Also:
-
NDC_FIELD
NDC string literal.- See Also:
-
EXCEPTION_FIELD
EXCEPTION string literal.- See Also:
-
TIMESTAMP_FIELD
TIMESTAMP string literal.- See Also:
-
THREAD_FIELD
THREAD string literal.- See Also:
-
PROP_FIELD
PROP. string literal.- See Also:
-
EMPTY_STRING
empty string literal.- See Also:
-
RESOLVER
LOGGER string literal.
-
-
Constructor Details
-
LoggingEventFieldResolver
private LoggingEventFieldResolver()Create new instance.
-
-
Method Details
-
applyFields
Apply fields.- Parameters:
replaceText
- replacement text.event
- logging event.- Returns:
- evaluted expression
-
getInstance
Get singleton instance.- Returns:
- singleton instance
-
isField
Determines if specified string is a recognized field.- Parameters:
fieldName
- field name- Returns:
- true if recognized field.
-
getValue
Get value of field.- Parameters:
fieldName
- fieldevent
- event- Returns:
- value of field
-
getExceptionMessage
Get message from throwable representation.- Parameters:
exception
- exception- Returns:
- message
-