ru.dmerkushov.loghelper.LogHelperUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of log-helper Show documentation
Show all versions of log-helper Show documentation
A library to help use different logging frameworks, such as java.util.logging (JUL) and Apache Log4j, even together. See also https://github.com/dmerkushov/log-helper-examples
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ru.dmerkushov.loghelper;
/**
*
* @author Dmitriy Merkushov
*/
public class LogHelperUtil {
/**
* Get the StackTraceElement of the method that called the caller of getCallerStackTraceElement ()
* @return may be null
*/
public static StackTraceElement getCallerStackTraceElement () {
StackTraceElement callerStackTraceElement = null;
StackTraceElement[] stackTraceElements = Thread.currentThread ().getStackTrace ();
if (stackTraceElements != null) {
if (stackTraceElements.length > 3) {
callerStackTraceElement = stackTraceElements[3];
}
}
return callerStackTraceElement;
}
}