My application has a homebrew logging class that I\'m migrating to using log4j under the covers. However, since I\'m using the homebrew class to pass the rest of the applica
In Log4J API about Logger.log(String callerFQCN, Priority level, Object message, Throwable t):
Parameters:
See: Log4J API.
Quite weird I know, argument is called "callerFQCN" which seams to be the caller object class, BUT (muajaja!) it's actually the "wrapper" class (ex MyClass.class.getName()).
Actually, the caller is get by the Throwable argument I think. Not sure, haven't checked the implementation.
As you leave Throwable argument null, I think something like this must be happening below:
StackTraceElement[] stack = (new Throwable()).getStackTrace();
String caller = stack[something, meaby 1].getClassName();
If you want to create a Logger wrapper you need to do something like this:
public static void myWarn(String message) {
myLogger.log(MyWrapper.class.getName(), message, Level.WARN, null);
}
This work without problem as a wrapper.
Or, if you absolutely need to maintain the interface you show below, do something like this:
// Warning: Pseudocode
public static void myWarn(Object source, String message) {
String sourceClass = source.class.GetName();
StackTraceElement[] stack = (new Throwable()).getStackTrace();
stack[1, or meaby 2... or 0?] = new whatever(sourceClass);
myLogger.log(MyWrapper.class.getName(), message, Level.WARN, myStack);
}
Hope this helps.