如何在 log4j.properties 中使用系统环境变量?

2022-01-15 00:00:00 environment-variables java log4j

我添加了系统环境值PROJECT_HOME=C:Program FilesProject

I added the system environment value PROJECT_HOME=C:Program FilesProject

现在我正在尝试使用 log4j.properties 中的系统环境值但没有设置它

Now i'm trying to use the system environment value in log4j.properties but didn't set it

**log4j.properties**
**log4j.appender.LOGFILE.File="${env.PROJECT_HOME}"/project.log**

能否请您告诉我如何在 log4j.properties 中设置系统环境变量?

Could you please tell me how to set system environment variables in log4j.properties?

使用log4j-1.2.7版本

推荐答案

EnvironmentLookup in log4j - 2. 查看示例.

This is supported by EnvironmentLookup in log4j - 2. See examples.

使用 ${sys:PROJECT_HOME} 代替 ${env.PROJECT_HOME}

相关文章