NTEventLogAppender(库已加载到另一个类加载器中)
我的 src 包上有一个像这样的 log4j.properties 文件:
log4j.rootLogger=DEBUG, CA, EVA
#Console Appender
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
#Event Viewer Appender
log4j.appender.EVA=org.apache.log4j.nt.NTEventLogAppender
log4j.appender.EVA.layout=org.apache.log4j.PatternLayout
log4j.appender.EVA.source=MySource
log4j.appender.EVA.layout.ConversionPattern=[%c][%l][%p][%thread]: %m%n
我在接口 (LogInterface.java) 上创建记录器,如下所示:
package components;
import org.apache.log4j.Logger;
public interface LogInterface {
static final Logger logger = Logger.getLogger("MyLogger");
}
我将 NTEventLogAppender.dll 放置在:
C:\Program Files (x86)\IBM\WID7_WTE\ 下runtimes\bi_v7\java\jre\bin
有时,当有异常要记录时,我会收到以下错误:
NTEventLogAppender(库已加载到另一个类加载器)
我该如何解决这个问题?
谢谢
I have a log4j.properties file like this on my src package:
log4j.rootLogger=DEBUG, CA, EVA
#Console Appender
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
#Event Viewer Appender
log4j.appender.EVA=org.apache.log4j.nt.NTEventLogAppender
log4j.appender.EVA.layout=org.apache.log4j.PatternLayout
log4j.appender.EVA.source=MySource
log4j.appender.EVA.layout.ConversionPattern=[%c][%l][%p][%thread]: %m%n
I create the logger on a interface (LogInterface.java) like this:
package components;
import org.apache.log4j.Logger;
public interface LogInterface {
static final Logger logger = Logger.getLogger("MyLogger");
}
I place the NTEventLogAppender.dll under:
C:\Program Files (x86)\IBM\WID7_WTE\runtimes\bi_v7\java\jre\bin
Sometimes I am getting the following error when there is an exception to log:
NTEventLogAppender (Library is already loaded in another ClassLoader)
How can I solve this issue?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题的解决方案是将log4j JAR文件放在:
Application_Server_Install_Path\lib
下 在项目上,我将log4j JAR文件作为变量添加到项目的构建路径中(添加变量选项)
这解决了IDE上的JAR引用唯一的问题剩下要做的就是在 Websphere Application Server 的运行时添加先前的 log4j JAR 文件引用。
为此,我访问了 WAS 管理控制台,并在以下位置添加了之前的 log4j JAR 文件路径:
Environment ->共享库
尽管似乎没有人遇到同样的问题,但这是未来类似问题的解决方案
谢谢
The solution for this problem was to place the log4j JAR file under:
Application_Server_Install_Path\lib
On the project I added the log4j JAR file to the project's build path as a variable (add variable option)
This solves the JAR reference on the IDE the only thing left to do is to add the previous log4j JAR file reference on the Websphere Application Server's runtime.
To do this I accessed the WAS administration console and added the previous log4j JAR file path under:
Environment -> Shared Libraries
Despite no one seems to have this same problem, here's the solution for future similar problems
Thanks