我目前正在使用与WAS v7集成的Java Util Loggers。我们有一个自定义单例Logger类..
公共类CustomLogger {
private Logger logger = null;
.. .. private CustomLogger(){ 超(); } 。 。 //返回记录器实例的方法,该实例从其他应用程序项目调用
public static CustomLogger getCustomLogger(String loggerName) {
CustomLogger customLogger = new CustomLogger();
// check if logger name is null
if (loggerName == null || loggerName.isEmpty())
loggerName = DEFAULT_LOGGER_NM;
// check if logger already exist in log manager.
LogManager logManager = LogManager.getLogManager();
try {
logManager.readConfiguration(readURLReference(LOGGING_PROPERTIES_URL_JNDI));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Logger loggerLocal = logManager.getLogger(loggerName);
if (loggerLocal == null) {
loggerLocal = Logger.getLogger(loggerName);
}
configure(loggerLocal);
loadProperties(readURLReference(LOGGING_PROPERTIES_URL_JNDI));
for (Handler tempHandler : loggerLocal.getHandlers()) {
tempHandler.flush();
tempHandler.close();
loggerLocal.removeHandler(tempHandler);
}
customLogger.setLogger(loggerLocal);
return customLogger;
}
我从WAS中的URL引用加载属性文件。
消耗记录器的地方,
private final CustomLogger logger = CustomLogger.getCustomLogger(className);
问题,
当我同时向2个不同EAR提供的2个不同服务发出并行请求时,我们编写的应用程序日志会混淆。是否有人遇到类似问题或对如何解决问题有任何想法?
谢谢, 希瓦