
de.galan.commons.logging.Logr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Additional common functionality for Java developers.
package de.galan.commons.logging;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.util.ReflectionUtil;
/**
* Returns the Log4j2 logger for the calling class (for Slf4j use Slogr). Can be used to determine the Logger, reduces
* errors when copy&paste.
* Note: Compareable to Log4j2 LogManager.getLogger();
*
* @author galan
*/
public class Logr {
// Using ReflectionUtil directly with "2" like the log4j2 LogManager.getLogger()
private static final int THREAD_TYPE_DEEP = 2;
/**
* To be used to get the Log4j2 Logger in a class, eg. private final static Logger LOG = Logr.get();
.
* To avoid the Logger declaration completely, use the class Say
.
*/
public static Logger get() {
return LogManager.getLogger(ReflectionUtil.getCallerClass(THREAD_TYPE_DEEP), PayloadMessageFactory.INSTANCE);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy