简体   繁体   English

Log4j-在Windows上访问环境变量

[英]Log4j - access to environment variable on Windows

How can I access to an environment variable named "LOGS_HOME" within my log4j.properties file. 如何在我的log4j.properties文件中访问名为“ LOGS_HOME”的环境变量。 Besides, I have deployed on WebLogic 11g several wars which need the value of this EV in order to create a directory and place there the log files. 此外,我已经在WebLogic 11g上部署了几次战争,这些战争需要此EV的值才能创建目录并将日志文件放置在该目录中。

BTW: I am using log4j 1.2.17 顺便说一句:我正在使用log4j 1.2.17

According to this answer , log4j version 2 can resolve your problem... 根据此答案 ,log4j版本2可以解决您的问题...

However, if you cannot change the log4j version, you can use the System Properties Substitution and pass the environment variable: LOGS_HOME as JAVA System Property when starting the server (example: runWebLogic.bat -Dlogs.home=%LOGS_HOME% ... NOTE: this is just an example, I really don't know how to start the weblogic server, but the idea it's the same). 但是,如果无法更改log4j版本,则可以使用“系统属性”替代,并在启动服务器时将环境变量LOGS_HOME作为JAVA系统属性传递(例如: runWebLogic.bat -Dlogs.home=%LOGS_HOME% ... 注意:这只是一个例子,我真的不知道如何启动weblogic服务器,但是想法是一样的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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