I have to use a separate class to for loggin instead of calling the LOGGER directly in every class i'd like to log.
I am using the following to do so:
import org.eclipse.e4.core.services.log.Logger
class A {
static Logger logger = PlatformUI.getWorkbench().getService(org.eclipse.e4.core.services.log.Logger.class)
public static void info(String message) {
logger.info(message);
}
}
class B {
A.info("Foobar");
}
Now when I call the Info() method it writes the following in the .log file: "[...] org.eclipse.e4.ui.workbench [...] !MESSAGE Foobar"
Question: How can I log the class from which the Logger was called without implementing the logger in that specific class. I want it to log something like "!MESSAGE Class A Foobar". So i know which class or at least Package the log entry comes from. Thank you!
The
Loggerclass Javadoc says it is not intended for end-user use.PlatformUIis not for pure e4 (you can't use anything inorg.eclipse.ui.xxxplug-ins).Instead you can use the
ILoginterface returned byPlatform.getLog(). The Java 9 and onwardsStackWalkercan be used to get the caller.I use something like: