[英]Problem with external log4j.properties file
我無法從外部文件加載 log4j.properties。 這有效,但我需要將位置從 server.xml 傳遞給它。 服務器是自由。 這適用於 configuration.properties 和 configuration.properties: server.xml:
<jndiURLEntry id="url/propiedades.conf" jndiName="url/propiedades.conf" value="file:${server.config.dir}conf/" />
資源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"
所有三個文件都在同一目錄中。
感謝您的回答
我通過向“configuration.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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.