Java 外部log4j.properties文件有问题
我无法从外部文件加载log4j.properties。这是可行的,但我需要将位置从server.xml传递给它。服务器是Liberty。 这适用于configuration.properties和configuration.properties: server.xml:Java 外部log4j.properties文件有问题,java,logging,log4j,Java,Logging,Log4j,我无法从外部文件加载log4j.properties。这是可行的,但我需要将位置从server.xml传递给它。服务器是Liberty。 这适用于configuration.properties和configuration.properties: server.xml: <jndiURLEntry id="url/propiedades.conf" jndiName="url/propiedades.conf" value="file:${
<jndiURLEntry id="url/propiedades.conf" jndiName="url/propiedades.conf" value="file:${server.config.dir}conf/" />
这三个文件都在同一个目录中
谢谢你的回答我通过在“configuration.properties”中添加属性来修复它 豆子:
<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>
<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"
<bean id="log4jInitializer"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="staticMethod"
value="org.apache.log4j.PropertyConfigurator.configure"/>
<property name="arguments">
<list>
<value>${log4j.dir}/log4j.properties</value>
</list>
</property>
</bean>
log4j.dir = ${server.config.dir}conf