简体   繁体   English

如何在Websphere中为log4j.properties文件设置相对路径

[英]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.

相关问题 为“ log4j.properties”文件设置绝对路径 - set an absolute path for a “log4j.properties” file 如何将log4j.properties文件的路径更改为特定路径? - How to change the path of the log4j.properties file to a specific one? 如何为子软件包设置log4j.properties文件 - How to set up a log4j.properties file for sub packages 如何在log4j.properties文件中为占位符设置值? - How to set values to placeholders in log4j.properties file? 如何在 log4j.properties 文件中设置 filePermissions - How to set filePermissions in log4j.properties file 如何在Eclipse中设置log4j.properties? - How to set log4j.properties in Eclipse? 如何在服务器上使用-Dlog4j.configuration = file:/path/to/log4j.properties运行我的flink作业 - how to run my flink job with -Dlog4j.configuration=file:/path/to/log4j.properties on server 如何在不使用绝对路径的情况下使用log4j.properties为Java Web Service创建日志文件 - How to use log4j.properties to create a log file for a Java Web Service without using an absolute path 在log4j.properties中,带空间的每日附加器文件路径不起作用 - In log4j.properties Daily appender file path with space not working 如何在log4j.properties文件中互助追加器属性? - How to mutualize appenders properties in log4j.properties file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM