All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.dmerkushov.loghelper.LogHelperUtil Maven / Gradle / Ivy

Go to download

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

There is a newer version: 2.0.2
Show newest version
/*
 * 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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy