Logging 在Mule MMC部署的应用程序初始化其log4j设置之前,如何设置系统属性?

Logging 在Mule MMC部署的应用程序初始化其log4j设置之前,如何设置系统属性?,logging,log4j,mule,Logging,Log4j,Mule,我想在我部署的Mule应用程序外部使用log4j.properties文件(将以不同的名称命名)。应用程序是使用MMC服务器部署的。在IDE的测试环境中,如果我设置了VM arg-Dlog4j.configuration=file:///c:/esb/etc/log4jconfig/log4j.myApp.properties,指向外部log4j属性文件,它可以工作 但是,让同一个应用程序在部署到Mule MMC登台环境时加载外部log4j属性文件还没有奏效 Maven Surefire插件可以

我想在我部署的Mule应用程序外部使用log4j.properties文件(将以不同的名称命名)。应用程序是使用MMC服务器部署的。在IDE的测试环境中,如果我设置了VM arg
-Dlog4j.configuration=file:///c:/esb/etc/log4jconfig/log4j.myApp.properties
,指向外部log4j属性文件,它可以工作

但是,让同一个应用程序在部署到Mule MMC登台环境时加载外部log4j属性文件还没有奏效

Maven Surefire插件可以工作,但这是针对测试环境的

我试过:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
            <execution>
                <goals>
                    <goal>set-system-properties</goal>
                </goals>
                <configuration>
                    <properties>
                        <property>
                            <name>my.property.name</name>
                            <value>my.property.value</value>
                        </property>
                    </properties>
                </configuration>
            </execution>
        </executions>
    </plugin>

org.codehaus.mojo
,在默认初始化过程下,我被告知设置
log4j.configuration
系统属性将覆盖日志属性文件的位置,正如我所说,当我在IDE测试中更改VM参数时,它会这样做

我需要一种方法让Mule在log4j初始化之前加载该系统属性


MMC中部署的Mule应用程序与其他几个部署的应用程序共享同一个Mule独立实例,我不想将所有这些应用程序的日志位置更改为同一位置。每个应用程序都必须有自己的应用程序。

您可以通过向配置中添加以下bean来实现这一点:

<spring:bean id="log4jInitialization"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <spring:property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
        <spring:property name="targetMethod" value="initLogging" />
        <spring:property name="arguments">
            <spring:list>
                <spring:value>file:///c:/esb/etc/log4jconfig/log4j.myApp.properties</spring:value>
            </spring:list>
        </spring:property>
</spring:bean>

file:///c:/esb/etc/log4jconfig/log4j.myApp.properties

谢谢,成功了。很好用!
<spring:bean id="log4jInitialization"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <spring:property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
        <spring:property name="targetMethod" value="initLogging" />
        <spring:property name="arguments">
            <spring:list>
                <spring:value>file:///c:/esb/etc/log4jconfig/log4j.myApp.properties</spring:value>
            </spring:list>
        </spring:property>
</spring:bean>