外部log4j.properties文件有问题

ztmd8pv5  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(258)

我无法从外部文件加载log4j.properties。这是可行的,但我需要将位置从server.xml传递给它。服务器是liberty。这适用于configuration.properties和configuration.properties:server.xml:

<jndiURLEntry id="url/propiedades.conf" jndiName="url/propiedades.conf" value="file:${server.config.dir}conf/" />

resource-beans.xml:

<bean id="beanPropertiesProyecto"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>${url/propiedades.conf}configurationBean.properties</value>
                <value>${url/propiedades.conf}configuration.properties</value>
            </list>
        </property>
    </bean>

对于文件log4j.properties,这起作用:resource-beans.xml:

<bean id="log4jInitializer"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="staticMethod"
            value="org.springframework.util.Log4jConfigurer.initLogging"/>
        <property name="arguments">
            <list>
            <value>file:${server.config.dir}conf/log4j.properties</value>
            </list>
        </property>
    </bean>

但这行不通

<bean id="log4jInitializer"
        class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="staticMethod"
            value="org.springframework.util.Log4jConfigurer.initLogging"/>
        <property name="arguments">
            <list>
            <value>${url/propiedades.conf}log4j.properties</value>
            </list>
        </property>
    </bean>

抛出此错误:

Invalid bean definition with name 'log4jInitializer' defined in class path resource [beans/business/resource-beans.xml]: Could not resolve placeholder 'url/propiedades.conf' in value "${url/propiedades.conf}log4j.properties"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'url/propiedades.conf' in value "${url/propiedades.conf}log4j.properties"

这三个文件都在同一个目录中。
谢谢你的回答

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题