Is it possible to provide custom location for the log4j.properties file for the log4j 1.x? I don't want to include the file in the project's resources folder.
Asked
Active
Viewed 1,463 times
1 Answers
1
configure the org.springframework.web.util.Log4jConfigListener
in your web.xml
with context-parameter log4jConfigLocation
.
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>file:C:/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
Bootstrap listener for custom log4j initialization in a web environment. Delegates to
Log4jWebConfigurer
...
Location of the log4j config file; either a "classpath:" location (e.g. "classpath:myLog4j.properties"), an absolute file URL (e.g. "file:C:/log4j.properties), or a plain path relative to the web application root directory (e.g. "/WEB-INF/log4j.properties"). If not specified, default log4j initialization will apply ("log4j.properties" or "log4j.xml" in the class path; see the log4j documentation for details). "log4jRefreshInterval":
-
Thanks Ralph. If I want to configure the file location programmatically, should I inject a custom Log4jWebConfigurer implementation? – superM Aug 19 '15 at 08:22