2012-07-30 94 views
0

我正在使用Tomcat作爲servlet容器,並且我必須檢查catalina.out日誌以便每天進行調試。但是當匿名用戶試圖登錄時,Spring Security攔截器會拋出異常,它會氾濫catalina.out日誌文件。日誌如下:如何禁用彈簧安全日誌記錄

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 
at java.lang.Thread.run(Thread.java:722) 
Caused by: org.springframework.security.authentication.AuthenticationCredentialsNotFoundException: An Authentication object was not found in the SecurityContext 
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:327) 
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:197) 
at org.springframework.flex.security3.EndpointInterceptor.preProcess(EndpointInterceptor.java:97) 
at org.springframework.flex.core.MessageInterceptionAdvice.invoke(MessageInterceptionAdvice.java:62) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:124) 
... 52 more 

如何在Tomcat中禁用Spring Security日誌記錄?

回答

3

當日志級別設置爲DEBUG並且過濾器鏈中沒有AnonymousAuthenticationFilter時,您將在日誌中看到AuthenticationCredentialsNotFoundException。

參見FAQ

因此,我假設您在安全應用程序上下文中使用傳統的bean配置而不是命名空間配置。如果你想擺脫例外,你可以作爲documentation

或者描述的anonymousAuthenticationFilter添加到您的應用程序上下文,你可以打開的

org.springframework.security.level=INFO 

Tomcat中的日誌級別在本question提到。