Java – use log4j to customize the log file name in mule
•
Java
I'm trying to modify log4j XML to use the appropriate appender to change the log file name generated by mule
This is log4j A fragment of XML
<RollingFile name="Rolling-Async-Perf" fileName="/usr/local/mule/logs/${app_name}.log" filePattern="./logs/${date:yyyy-MM}/perf-%d{yyyy-MM-dd}-%i.log.gz" immediateFlush="false">
Here's what I'm loading with log4j Set application in the class of XML related properties_ Method for the value of name
System.setProperty("app_name","AppName");
However, the generated file name is ${app_name} Log instead of appName log.
Any ideas on how to get file names based on custom attributes in mule?
Solution
There are two options:
1) In mule_ HOME / conf / wrapper. Add an attribute to the conf file, for example:
wrapper.java.additional.15=-Dapp_name=AppName
Or 2) in log4j2 In the configuration element of the XML file example here:
<Properties> <Property name="app_name">AppName</Property> </Properties>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码