<tfoot id='5xLfX'></tfoot>
      <legend id='5xLfX'><style id='5xLfX'><dir id='5xLfX'><q id='5xLfX'></q></dir></style></legend>
      <i id='5xLfX'><tr id='5xLfX'><dt id='5xLfX'><q id='5xLfX'><span id='5xLfX'><b id='5xLfX'><form id='5xLfX'><ins id='5xLfX'></ins><ul id='5xLfX'></ul><sub id='5xLfX'></sub></form><legend id='5xLfX'></legend><bdo id='5xLfX'><pre id='5xLfX'><center id='5xLfX'></center></pre></bdo></b><th id='5xLfX'></th></span></q></dt></tr></i><div id='5xLfX'><tfoot id='5xLfX'></tfoot><dl id='5xLfX'><fieldset id='5xLfX'></fieldset></dl></div>
    1. <small id='5xLfX'></small><noframes id='5xLfX'>

        <bdo id='5xLfX'></bdo><ul id='5xLfX'></ul>

        如何在 log4j 的配置文件中为文件附加程序提供环境变量路径

        时间:2023-07-14
        • <bdo id='ba0ra'></bdo><ul id='ba0ra'></ul>

            <tbody id='ba0ra'></tbody>
        • <small id='ba0ra'></small><noframes id='ba0ra'>

          <i id='ba0ra'><tr id='ba0ra'><dt id='ba0ra'><q id='ba0ra'><span id='ba0ra'><b id='ba0ra'><form id='ba0ra'><ins id='ba0ra'></ins><ul id='ba0ra'></ul><sub id='ba0ra'></sub></form><legend id='ba0ra'></legend><bdo id='ba0ra'><pre id='ba0ra'><center id='ba0ra'></center></pre></bdo></b><th id='ba0ra'></th></span></q></dt></tr></i><div id='ba0ra'><tfoot id='ba0ra'></tfoot><dl id='ba0ra'><fieldset id='ba0ra'></fieldset></dl></div>
          <tfoot id='ba0ra'></tfoot>

                <legend id='ba0ra'><style id='ba0ra'><dir id='ba0ra'><q id='ba0ra'></q></dir></style></legend>
                  本文介绍了如何在 log4j 的配置文件中为文件附加程序提供环境变量路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 log4j.xml 配置文件.和一个 RollingFileAppender 我需要提供用于存储日志的文件路径.问题是我的代码将作为可运行的 jar 部署在 Unix 机器上.所以如果我传递这样的参数:

                  I have a log4j.xml config file. and a RollingFileAppender to which I need to provide file path for storing logs. The problem is my code will be deployed on Unix machine as a runnable jar. So if I pass parameter something like this:

                  value=logs/messages.log"
                  

                  它在我的 HOME 目录中创建名为 logs 的文件夹,并将所有消息写入此目录中的文件.

                  it creates folder named logs inside my HOME directory and writes all the messages to file inside this directory.

                  我将环境变量设置为某个值.我想使用该变量的路径并在该路径下写入消息.我怎样才能实现它?

                  I have a environmental variable set to some value. I want to use path of that variable and write messages under that path. How can I achieve it?

                  我试过用这个:

                  value="${MY_HOME}/logs/message.log"
                  

                  但这不起作用.任何人都可以提出解决这个问题的方法吗?

                  but this does not work. Can anyone suggest a solution for this problem?

                  推荐答案

                  解析其配置文件时,表达式${MY_HOME}会被展开为系统属性的值 命名为 MY_HOME,而不是系统 环境变量.两者是有区别的.

                  When parsing its configuration file, the expression ${MY_HOME} will be expanded to the value of the system property named MY_HOME, not the system environment variable. There's a difference between the two.

                  要以简洁的方式实现这一点,您必须在 JVM 调用行中添加类似这样的内容:

                  To achieve this in a clean way, you'll have to add something like this to the JVM invocation line:

                  -DMY_HOME=$MY_HOME

                  这将定义 Java 系统属性 MY_HOME 以包含环境变量 MY_HOME 的值.

                  That would define the Java system property MY_HOME to contain the value of the environment variable MY_HOME.

                  这篇关于如何在 log4j 的配置文件中为文件附加程序提供环境变量路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 log4j xml 配置中使用系统环境变量 下一篇:在 web.xml 中引用环境变量

                  相关文章

                    <bdo id='O13Dl'></bdo><ul id='O13Dl'></ul>
                  1. <small id='O13Dl'></small><noframes id='O13Dl'>

                    <legend id='O13Dl'><style id='O13Dl'><dir id='O13Dl'><q id='O13Dl'></q></dir></style></legend>
                    <i id='O13Dl'><tr id='O13Dl'><dt id='O13Dl'><q id='O13Dl'><span id='O13Dl'><b id='O13Dl'><form id='O13Dl'><ins id='O13Dl'></ins><ul id='O13Dl'></ul><sub id='O13Dl'></sub></form><legend id='O13Dl'></legend><bdo id='O13Dl'><pre id='O13Dl'><center id='O13Dl'></center></pre></bdo></b><th id='O13Dl'></th></span></q></dt></tr></i><div id='O13Dl'><tfoot id='O13Dl'></tfoot><dl id='O13Dl'><fieldset id='O13Dl'></fieldset></dl></div>

                    1. <tfoot id='O13Dl'></tfoot>