springMVC項目中配置log4j.properties路徑


log4j.properties不打到war包中,單獨寫到一個存放配置文件的文件夾中,在容器中將該文件夾放入classpath,在web.xml中可以如下配置:

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext-dao.xml,classpath:SpringMVC.xml
    </param-value>
  </context-param>


  <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>classpath:db2client-cfg/log4j.properties</param-value>
  </context-param>

  <context-param>
    <param-name>log4jRefreshInterval</param-name>
    <param-value>60000</param-value>
  </context-param>

  <!-- 配置log4j.xml監聽器-->
  <!--需要配置在 ContextLoaderListener之前-->
  <listener>
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
  </listener>

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM