Package org.apache.logging.log4j.util
Class StackLocatorUtil
- java.lang.Object
-
- org.apache.logging.log4j.util.StackLocatorUtil
-
public final class StackLocatorUtil extends Object
Consider this class private. Provides various methods to determine the caller class.Background
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StackTraceElement
calcLocation(String fqcnOfLogger)
static Class<?>
getCallerClass(int depth)
static Class<?>
getCallerClass(Class<?> anchor)
static Class<?>
getCallerClass(Class<?> sentinelClass, Predicate<Class<?>> callerPredicate)
Search for a calling class.static Class<?>
getCallerClass(String fqcn)
Equivalent togetCallerClass(String, String)
with an emptypkg
.static Class<?>
getCallerClass(String fqcn, String pkg)
Search for a calling class.static Stack<Class<?>>
getCurrentStackTrace()
static StackTraceElement
getStackTraceElement(int depth)
-
-
-
Method Detail
-
getCallerClass
public static Class<?> getCallerClass(int depth)
-
getStackTraceElement
public static StackTraceElement getStackTraceElement(int depth)
-
getCallerClass
public static Class<?> getCallerClass(String fqcn)
Equivalent togetCallerClass(String, String)
with an emptypkg
.
-
getCallerClass
public static Class<?> getCallerClass(String fqcn, String pkg)
Search for a calling class.- Parameters:
fqcn
- Root class name whose caller to search for.pkg
- Package name prefix that must be matched after thefqcn
has been found.- Returns:
- The caller class that was matched, or null if one could not be located.
-
getCallerClass
public static Class<?> getCallerClass(Class<?> sentinelClass, Predicate<Class<?>> callerPredicate)
Search for a calling class.- Parameters:
sentinelClass
- Sentinel class at which to begin searchingcallerPredicate
- Predicate checked after the sentinelClass is found- Returns:
- the first matching class after
sentinelClass
is found.
-
calcLocation
public static StackTraceElement calcLocation(String fqcnOfLogger)
-
-