且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用环境变量将log4j2.xml文件加载到项目外部

更新时间:2023-11-24 18:37:22

Log4j插入它在web.xml中为log4jConfiguration找到的值.但是,您必须使用标准的Log4j查找语法.要获取环境变量,您可以指定:

Log4j interpolates the value it finds for log4jConfiguration in web.xml. However, you have to use standard Log4j Lookup syntax. To get an environment variable you would specify:

<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>file:///${env:ENVIROMENT_VARIABLE}/log4j2.xml</param-value>
</context-param>