2012-03-06 166 views
0

當我在庫中添加log4j.jar時,Spring RESTful Web服務未加載。控制檯日誌: 春季RESTful服務問題

Mar 5, 2012 1:36:35 PM org.apache.catalina.core.ApplicationContext log 
INFO: Initializing Spring FrameworkServlet 'policy' 
Mar 5, 2012 1:36:36 PM org.apache.coyote.http11.Http11Protocol start 
INFO: Starting Coyote HTTP/1.1 on http-8080
它正在初始化servlet,但在此之後不加載服務。

但是,如果我刪除log4j.jar,一切工作正常。控制檯日誌:

Mar 5, 2012 1:32:36 PM org.springframework.web.servlet.FrameworkServlet initServletBean 
INFO: FrameworkServlet 'policy': initialization started 
Mar 5, 2012 1:32:37 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh 
INFO: Refreshing WebApplicationContext for namespace 'policy-servlet': startup date [Mon Mar 05 13:32:37 EST 2012]; root of context hierarchy

我在我的庫中有commons-logging.jar來運行Spring。

回答

0

我已經解決了在我的課文件夾中添加long4j.xml並添加DTD規範,它這個問題。 早些時候我使用的是log4j.properties,而log4j.jar沒有識別它。

1

是的commons-logging可以用於Spring。我會建議使用slf4j代替。這是基於對commons-logging和log4j的討厭的個人經驗。

我會建議使用一個構建工具來清理你的依存關係:

行家:http://maven.apache.org/ 或 gradle這個:http://gradle.org/

我也建議不要使用公共記錄。這是一個個人選擇,但我使用slf4j是因爲我在使用log4j和commons-logging時遇到的類加載問題。

使用Maven可以排除共享記錄

<dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-webmvc</artifactId> 
    <version>${spring.version}</version> 
    <exclusions> 
     <exclusion> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 

,然後包括SLF4J記錄

+0

謝謝@chrislovecnm – 2012-03-06 20:53:32