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 StringCLASS string literal.static final Stringempty string literal.static final StringEXCEPTION string literal.static final StringFILE string literal.static final ListKeyword list.static final StringLEVEL string literal.static final StringLINE string literal.static final StringLOGGER string literal.static final StringMETHOD string literal.static final StringMSG string literal.static final StringNDC string literal.static final StringPROP.private static final LoggingEventFieldResolverLOGGER string literal.static final StringTHREAD string literal.static final StringTIMESTAMP string literal. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyFields(String replaceText, org.apache.log4j.spi.LoggingEvent event) Apply fields.private static StringgetExceptionMessage(String[] exception) Get message from throwable representation.static LoggingEventFieldResolverGet singleton instance.Get value of field.booleanDetermines if specified string is a recognized field.
-
Field Details
-
KEYWORD_LIST
Keyword list. -
LOGGER_FIELD
-
LEVEL_FIELD
-
CLASS_FIELD
-
FILE_FIELD
-
LINE_FIELD
-
METHOD_FIELD
-
MSG_FIELD
-
NDC_FIELD
-
EXCEPTION_FIELD
-
TIMESTAMP_FIELD
-
THREAD_FIELD
-
PROP_FIELD
-
EMPTY_STRING
-
RESOLVER
LOGGER string literal.
-
-
Constructor Details
-
LoggingEventFieldResolver
private LoggingEventFieldResolver()Create new instance.
-
-
Method Details
-
applyFields
-
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
-
getExceptionMessage
-