[英]How to set relative path for log4j.properties file in Websphere
Hi i am trying to set the log4j.properties path under websphere custom properties as a relative path which is not working. 嗨,我正在尝试将Websphere自定义属性下的log4j.properties路径设置为相对路径,该路径不起作用。
Setting Location: 设置位置:
Middleware servers > cluster1node1 > Process definition > Java Virtual Machine > Custom properties 中间件服务器> cluster1node1>进程定义> Java虚拟机>定制属性
This is working: 这正在工作:
Property name: log4j.configuration
Value: file:/dir1/dir2/my_configs/log4j.properties
This is NOT working. 这是行不通的。
Property name: log4j.configuration
Value: ${CONFIG_ROOT}/my_configs/log4j.properties
Where config root is a websphere variable as below; 其中config root是一个websphere变量,如下所示;
Name: CONFIG_ROOT
Value: /dir1/dir2/
Can someone tell me what possibly i am doing wrong here? 有人可以告诉我在这里我做错了什么吗? I am able to use the similar relative path successfully for a normal application config file. 我可以为普通的应用程序配置文件成功使用类似的相对路径。 Seems like this issue is applicable for just log4j.properties file. 似乎此问题仅适用于log4j.properties文件。
LATEST UPDATE: 最新更新:
Actually the issue is more related to the filesytem as when i pre-fixed the relative path with file: it worked. 实际上,这个问题与fileytem更相关,因为当我用file预先固定相对路径时:它起作用了。
This is working now. 现在正在工作。
Property name: log4j.configuration
Value: file:${CONFIG_ROOT}/my_configs/log4j.properties
But why is that? 但是为什么呢? Why it is not working without file: ? 为什么没有文件就无法工作: And how to make it work without file: 以及如何使其在没有文件的情况下工作:
根据此答案中解释的log4j默认初始化过程,log4j尝试将log4j.configuration的值转换为URL,因此需要文件:
The issue was more related to the filesytem because when i pre-fixed the relative path with file: it worked. 这个问题与filesytem更相关,因为当我用file预先固定相对路径时:它起作用了。
This is working now. 现在正在工作。
Property name: log4j.configuration
Value: file:${CONFIG_ROOT}/my_configs/log4j.properties
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.