歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Spring中Log4j高級配置

Spring中Log4j高級配置

日期:2017/3/1 10:04:16   编辑:Linux編程

Spring對Log4j支持的入口類是一個ServletContextListener。

Log4jConfigListener


Log4jWebConfigurer

Log4jWebConfigurer中有三個主要的屬性,它們都是可以在web.xml中配置的:

1. Log4jConfigLocation:Log4j配置文件的位置

2. Log4jRefreshInterval:檢測Log4j配置文件是否改變的時間間隔

3. Log4jExposeWebAppRoot:應用是否可以通過System.getProperties(“webAppRootKey”)得到當前應用名。

這三個屬性具體是如何被Spring運用,還要進入initLogging()方法一探究竟。

WebUtils就是將webAppRootKey屬性和值設置到System.setProperty()

配置文件位置和刷新頻率都是通過傳給Log4jConfigurer的initLogging()來實現的。

Copyright © Linux教程網 All Rights Reserved