简体   繁体   中英

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.

Setting Location:

Middleware servers > cluster1node1 > Process definition > Java Virtual Machine > Custom properties

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;

 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.

LATEST UPDATE:

Actually the issue is more related to the filesytem as when i pre-fixed the relative path with file: it worked.

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.

This is working now.

 Property name: log4j.configuration 
 Value: file:${CONFIG_ROOT}/my_configs/log4j.properties 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM