我可以使用以下配置在我的 spring 应用程序中读取属性文件(注意类路径中的通配符)
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath*:*/**/test*.properties</value>
</property>
但是,当我使用相同的通配符模式使用org.springframework.web.util.Log4jConfigListener
in指定自定义 Log4j 属性文件时web.xml
,它会因讨厌而失败,FileNotFoundException
并且 Log4j 未初始化。
有人可以帮我解决这个问题,并指出我在这里缺少什么。
web.xml
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath*:*/**/customLog4j*.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
PS:我知道财产占位符,即。${SOME_PLACE_HOLDER}
(我们可以用相应的系统/环境属性替换占位符值)在我的情况下无法应用,因为我们无法控制设置此类系统/环境属性并且必须使用通配符来解析自定义 log4j 属性的路径.