2012-07-30 71 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提到。