Your question
Right now if the application class path does not contains a well-known logging backend (like Logback, Log4j and etc) the created logger gets fixed predefined name "com.alipay.sofa.common.log".
So if an app uses a library like SOFAJRaft and uses a not very popular Slf4j-compatible logging backend (for example, GFLog) then all logging that is produced by that library gets default logger name "com.alipay.sofa.common.log". As result, it is impossible to control logging levels of different parts of the library separately.
Example:
Logger log = LoggerSpaceManager.getLoggerBySpace("someLoggerSpace", "someLoggerName");
// Returns logger with name "com.alipay.sofa.common.log".
// "someLoggerSpace" or "someLoggerName" are not included into the logger name at all
Your scenes
We need to control logging levels for different parts of the app separately because logs from different parts have different importance levels even if there is no logging backend known by sofa-common-tools.
Your advice
I think its necessary to modify MultiAppLoggerSpaceManager.NOP_LOGGER_FACTORY to actually take in account provided logger name instead of just defaulting to a Constants.DEFAULT_LOG:
private static final AbstractLoggerSpaceFactory NOP_LOGGER_FACTORY = new AbstractLoggerSpaceFactory(
"nop") {
@Override
public Logger getLogger(String name) {
return LoggerFactory.getLogger("com.alipay.sofa.common.log." + name);
}
};
Ideally it would be nice to also take the space into the account but for that it would be necessary to modify MultiAppLoggerSpaceManager to create new instances of AbstractLoggerSpaceFactory instead of using single NOP_LOGGER_FACTORY if no pre-defined logging backend is found.
Alternatively, it would be nice to have support of custom logging backend so it would be possible to utilize other logging backends that are not explicitly mentioned in MultiAppLoggerSpaceManager.createILoggerFactory(...)
Environment
- sofa-common-tools version: 1.0.12 (transitive from
jraft-core:1.3.9)
- JVM version (e.g.
java -version): openjdk version "11.0.13"
Your question
Right now if the application class path does not contains a well-known logging backend (like Logback, Log4j and etc) the created logger gets fixed predefined name "com.alipay.sofa.common.log".
So if an app uses a library like SOFAJRaft and uses a not very popular Slf4j-compatible logging backend (for example, GFLog) then all logging that is produced by that library gets default logger name "com.alipay.sofa.common.log". As result, it is impossible to control logging levels of different parts of the library separately.
Example:
Your scenes
We need to control logging levels for different parts of the app separately because logs from different parts have different importance levels even if there is no logging backend known by sofa-common-tools.
Your advice
I think its necessary to modify
MultiAppLoggerSpaceManager.NOP_LOGGER_FACTORYto actually take in account provided logger name instead of just defaulting to aConstants.DEFAULT_LOG:Ideally it would be nice to also take the space into the account but for that it would be necessary to modify
MultiAppLoggerSpaceManagerto create new instances ofAbstractLoggerSpaceFactoryinstead of using singleNOP_LOGGER_FACTORYif no pre-defined logging backend is found.Alternatively, it would be nice to have support of custom logging backend so it would be possible to utilize other logging backends that are not explicitly mentioned in
MultiAppLoggerSpaceManager.createILoggerFactory(...)Environment
jraft-core:1.3.9)java -version): openjdk version "11.0.13"