Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java log4j2查找websphere环境变量_Java_Log4j_Websphere_Log4j2_Websphere 8 - Fatal编程技术网

Java log4j2查找websphere环境变量

Java log4j2查找websphere环境变量,java,log4j,websphere,log4j2,websphere-8,Java,Log4j,Websphere,Log4j2,Websphere 8,我将log4j2版本2.10.0与IBM Websphere 8.5.5.12一起使用。 问题是我的log4j2.properties中的Websphere环境变量没有得到解决。我试过一些方法,比如 property.filename = $${sys:Test}/Test.log property.filename = ${env:Test}/Test.log 但无论我尝试什么,它都不是解决测试。有谁能帮我解决这个问题吗?如果您在正确的资源范围内创建了可供JVM访问的变量,可以通过添加与We

我将log4j2版本2.10.0与IBM Websphere 8.5.5.12一起使用。 问题是我的log4j2.properties中的Websphere环境变量没有得到解决。我试过一些方法,比如

property.filename = $${sys:Test}/Test.log
property.filename = ${env:Test}/Test.log

但无论我尝试什么,它都不是解决测试。有谁能帮我解决这个问题吗?

如果您在正确的资源范围内创建了可供JVM访问的变量,可以通过添加与Websphere环境变量同名的JVM自定义属性和如下所示的值来解决此问题:

Steps : In WAS Admin console, Go to 
    WebSphere application servers > 
        Server_name > 
            Java and Process Management (under Server Infrastructure)> 
                Process definition > 
                    Java Virtual Machine (under Additional Properties)> 
                        Custom properties
Click on New and enter below details : 
    Name  : Test
    Value : ${Test}
Apply and save the changes.
property.filename = ${Test}/Test.log
重新启动JVM并重新测试

编辑:如下面的注释所述,添加JVM自定义属性后,可以直接从log4j文件访问变量,如下所示:

Steps : In WAS Admin console, Go to 
    WebSphere application servers > 
        Server_name > 
            Java and Process Management (under Server Infrastructure)> 
                Process definition > 
                    Java Virtual Machine (under Additional Properties)> 
                        Custom properties
Click on New and enter below details : 
    Name  : Test
    Value : ${Test}
Apply and save the changes.
property.filename = ${Test}/Test.log

这是起作用的部分。问题是,我的log4j2.properties文件中的变量没有解析为WebSpherei中的环境变量。如果您设置了JVM自定义属性,那么您可以直接在log4j中访问该变量,如下所示。property.filename=${Test}/Test.loga一些事情,首先我使用环境->websphere变量来定义变量。我不确定那是不是对的。第二次尝试你的方式,但也没有结果。第三:值我用一个路径填充,当我以您的方式定义变量时,我在其工作的属性文件中使用前缀sys:。让我们看看它是否在真正的服务器上以相同的方式定义,而不是在本地服务器上定义