Class SourceResolver
java.lang.Object
org.apache.logging.log4j.layout.template.json.resolver.SourceResolver
- All Implemented Interfaces:
EventResolver,TemplateResolver<LogEvent>
Resolver for the
StackTraceElement returned by LogEvent.getSource().
Note that this resolver is toggled by locationInfoEnabled
layout configuration, which is by default populated from log4j.layout.jsonTemplate.locationInfoEnabled
system property.
Configuration
config = "field" -> (
"className" |
"fileName" |
"methodName" |
"lineNumber" )
Examples
Resolve the line number:
{
"$resolver": "source",
"field": "lineNumber"
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final EventResolverprivate static final EventResolverprivate final EventResolverprivate static final EventResolverprivate final booleanprivate static final EventResolverprivate static final EventResolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static EventResolvercreateInternalResolver(EventResolverContext context, TemplateResolverConfig config) (package private) static StringgetName()booleanIndicates if the resolver if applicable at all.booleanisResolvable(LogEvent logEvent) Indicates if the resolver if applicable for the givenvalue.voidresolve(LogEvent logEvent, JsonWriter jsonWriter) Resolves the givenvalueusing the providedJsonWriter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.logging.log4j.layout.template.json.resolver.TemplateResolver
isFlattening, resolve
-
Field Details
-
NULL_RESOLVER
-
CLASS_NAME_RESOLVER
-
FILE_NAME_RESOLVER
-
LINE_NUMBER_RESOLVER
-
METHOD_NAME_RESOLVER
-
locationInfoEnabled
private final boolean locationInfoEnabled -
internalResolver
-
-
Constructor Details
-
SourceResolver
SourceResolver(EventResolverContext context, TemplateResolverConfig config)
-
-
Method Details
-
createInternalResolver
private static EventResolver createInternalResolver(EventResolverContext context, TemplateResolverConfig config) -
getName
-
isResolvable
public boolean isResolvable()Description copied from interface:TemplateResolverIndicates if the resolver if applicable at all.For instance, the source line resolver can be short-circuited using this check if the location information is disabled in the layout configuration.
- Specified by:
isResolvablein interfaceTemplateResolver<LogEvent>
-
isResolvable
Description copied from interface:TemplateResolverIndicates if the resolver if applicable for the givenvalue.For instance, the stack trace resolver can be short-circuited using this check if the stack traces are disabled in the layout configuration.
- Specified by:
isResolvablein interfaceTemplateResolver<LogEvent>
-
resolve
Description copied from interface:TemplateResolverResolves the givenvalueusing the providedJsonWriter.- Specified by:
resolvein interfaceTemplateResolver<LogEvent>
-