mule 3.6.2中mule应用程序文件的log4j2.xml配置
如何从mule 3.6.2中的mule应用程序的特定文件(如“/opt/applications/app1/log/config/log4j2.xml”)中获取配置。常见的方法是从存储在资源文件夹中的配置文件log4j2.xml获取配置,我们需要从其他外部路径读取此配置文件。默认情况下,Mule使用自己的log4j2文件进行日志记录。要从外部路径读取log4j2.xml配置文件,请在文件应用程序上下文中添加下一个bean,以便指定要在Mule的常规上下文中使用的外部文件 应用程序上下文:mule 3.6.2中mule应用程序文件的log4j2.xml配置,mule,log4j2,Mule,Log4j2,如何从mule 3.6.2中的mule应用程序的特定文件(如“/opt/applications/app1/log/config/log4j2.xml”)中获取配置。常见的方法是从存储在资源文件夹中的配置文件log4j2.xml获取配置,我们需要从其他外部路径读取此配置文件。默认情况下,Mule使用自己的log4j2文件进行日志记录。要从外部路径读取log4j2.xml配置文件,请在文件应用程序上下文中添加下一个bean,以便指定要在Mule的常规上下文中使用的外部文件 应用程序上下文:
<bean id="loggerContext" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass">
<value> org.apache.logging.log4j.LogManager</value>
</property>
<property name="targetMethod">
<value>getContext</value>
</property>
<property name="arguments">
<value>false</value>
</property>
</bean>
<bean id="loggerContext1" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="loggerContext" />
<property name="targetMethod">
<value>setConfigLocation</value>
</property>
<property name="arguments">
<value>${log4j.external.path}</value>
</property>
</bean>
<bean id="loggerContext2" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="loggerContext" />
<property name="targetMethod">
<value>reconfigure</value>
</property>
</bean>
org.apache.logging.log4j.LogManager
getContext
假的
设置配置位置
${log4j.external.path}
重新配置
然后,您需要从文件Mule流中导入此上下文,使用:
骡子配置
<mule xmlns:https="http://www.mulesoft.org/schema/mule/https"
xmlns="http://www.mulesoft.org/schema/mule/core"
{..}
<!-- Add this: -->
<spring:beans>
<spring:import resource="classpath*:application-context.xml" />
</spring:beans>
{..}
<flow name="http-name" >
{..}
</flow>
</mule>
那么是否需要导入应用程序上下文?或者我可以在mule配置文件中进行配置?是的,可以在mule配置文件中进行配置,但我建议您分离mule。