Open gidxl03 opened 3 years ago
I would like to be added as a contributor, github profile gidxl03. I have a working solution
Add default interface method
public interface StackLogger extends LogLevels {
/**
* Invoked on first usage of the logger
* @param clazz
* @return instance of the stack logger for the given class
*/
default StackLogger getLoggerInstance(Class<?> clazz) {return this;}
Modify existing method in StackLogger
public static StackLogger getLogger(Class<?> clazz) {
if (useLegacyLogger && legacyLogger != null) {
return legacyLogger.getLoggerInstance(clazz);
}
return getLogger(clazz.getName());
}
Rejected Solution Application creates ‘gov.nist.core.CommonLoggerLog4j’ with a custom implementation and loads it first in the classpath
/kind feature
What happened: The class context of the logger is lost when supplying a custom implementation of
gov.nist.core.StackLogger
, becausegov.nist.core.CommonLogger
variable 'name' is never passed to the logger.What you expected to happen: The NIST stack logs include the name of the logger Example
How to reproduce it (as minimally and precisely as possible): Provide an implementation of gov.nist.core.StackLogger using a Logger such as Log4j2 and set property
gov.nist.javax.sip.STACK_LOGGER
to MyCustomStackLogger.class.getName()Anything else we need to know?: Note that gov.nist.core.CommonLogger will create a new CommonLogger instance with the name of the logging class but the name is never used and CommonLogger adds no value.
Environment: All Environments