Class SourceResolver

  • All Implemented Interfaces:
    EventResolver, TemplateResolver<LogEvent>

    public final class SourceResolver
    extends Object
    implements EventResolver
    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"
     }
     
    • Method Detail

      • isResolvable

        public boolean isResolvable()
        Description copied from interface: TemplateResolver
        Indicates 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:
        isResolvable in interface TemplateResolver<LogEvent>
      • isResolvable

        public boolean isResolvable​(LogEvent logEvent)
        Description copied from interface: TemplateResolver
        Indicates if the resolver if applicable for the given value.

        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:
        isResolvable in interface TemplateResolver<LogEvent>