首页 > 解决方案 > log4j:在 Windows 上的 Websphere 上找不到资源

问题描述

我在C:\log\server-log4j.xmlWindows 操作系统的文件夹中有一个 log4j 的配置文件。

在 Websphere Application Server 中,我尝试了以下 JVM 开关 - 所有这些都会导致log4j: Could not find resource服务器启动日志:

-Dlog4j.debug -Dlog4j.configuration="file:///log/server-log4j.xml" -Dlogging.config="file:///log/server-log4j.xml"

-Dlog4j.debug -Dlog4j.configuration="file:/C:/log/server-log4j.xml" -Dlogging.config="file:/C:/log/server-log4j.xml"

-Dlog4j.debug -Dlog4j.configuration="C:/log/server-log4j.xml" -Dlogging.config="C:/log/server-log4j.xml"

-Dlog4j.debug -Dlog4j.configuration="file:C:\log\server-log4j.xml" -Dlogging.config="file:C:\log\server-log4j.xml"

应用服务器启动日志的完整跟踪如下:

[16/03/21 09:20:01:784 GMT] 00000045 SystemOut     O log4j: Trying to find ["C:/log/server-log4j.xml"] using context classloader 
com.ibm.ws.classloader.CompoundClassLoader@e7f8d850[war:app/app-web.war]
   Local ClassPath: C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\ServerNode01Cell\app.ear\app-web.war\WEB-INF\classes;C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\ServerNode01Cell\app.ear\app-web.war
   Parent: com.ibm.ws.classloader.CompoundClassLoader@3ef04a80[PF][app]
   Delegation Mode: PARENT_LAST.
[16/03/21 09:20:01:846 GMT] 00000045 SystemOut     O log4j: Trying to find ["C:/log/server-log4j.xml"] using com.ibm.ws.bootstrap.ExtClassLoader@7548c7a5 class loader.
[16/03/21 09:20:01:846 GMT] 00000045 SystemOut     O log4j: Trying to find ["C:/log/server-log4j.xml"] using ClassLoader.getSystemResource().
[16/03/21 09:20:01:862 GMT] 00000045 SystemOut     O log4j: Could not find resource: ["C:/log/server-log4j.xml"].

什么是正确的语法?

标签: javalogginglog4j

解决方案


推荐阅读