Mule 3.6:Log4j2:如何读取 java vm 参数
Mule 3.6 : Log4j2: How to read java vm arguments
有没有办法读取 log4j2.xml 中的 java vm 参数?
${jvmrunargs:argname} 不起作用。
我在 Mule 的 wrapper.conf 中的论点必须在 log 4j 日志模式中阅读。
根据log4j2 documentation jvmrunargs 可以是
A JVM input argument accessed through JMX, but not a main argument
你也是这样吗?
你试过Main Arguments lookup了吗?
在您的代码中,您需要手动将应用程序的主要参数提供给 Log4j:
import org.apache.logging.log4j.core.lookup.MapLookup;
public static void main(String args[]) {
MapLookup.setMainArguments(args);
...
}
然后在配置中你可以这样做:
<File name="Application" fileName="application.log">
<PatternLayout header="Startup params: ${main:0} ${main:1} ${main:2}">
<Pattern>%d %m%n</Pattern>
</PatternLayout>
</File>
${sys} 有效。该文档不是那么描述性..但确实涵盖了这个
有没有办法读取 log4j2.xml 中的 java vm 参数? ${jvmrunargs:argname} 不起作用。 我在 Mule 的 wrapper.conf 中的论点必须在 log 4j 日志模式中阅读。
根据log4j2 documentation jvmrunargs 可以是
A JVM input argument accessed through JMX, but not a main argument
你也是这样吗?
你试过Main Arguments lookup了吗?
在您的代码中,您需要手动将应用程序的主要参数提供给 Log4j:
import org.apache.logging.log4j.core.lookup.MapLookup;
public static void main(String args[]) {
MapLookup.setMainArguments(args);
...
}
然后在配置中你可以这样做:
<File name="Application" fileName="application.log">
<PatternLayout header="Startup params: ${main:0} ${main:1} ${main:2}">
<Pattern>%d %m%n</Pattern>
</PatternLayout>
</File>
${sys} 有效。该文档不是那么描述性..但确实涵盖了这个