我目前正在使用与 WAS v7 集成的 Java Util Loggers。我们有一个自定义的单例 Logger 类..
公共类 CustomLogger {
private Logger logger = null;
.. .. private CustomLogger() { super(); } 。. // 返回记录器实例的方法,该实例是从其他应用程序项目中调用的,
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 引用加载属性文件。
消耗伐木机的地方,
私有最终 CustomLogger 记录器 = CustomLogger.getCustomLogger(className);
问题,
当我同时向 2 个不同 EAR 上的 2 个不同服务发出并行请求时,我们编写的应用程序日志会混淆。有没有人遇到过类似的问题或对如何解决有任何想法?
谢谢,湿婆