Journaling at the DEBUG level in Spring MVC is designed to be compact, minimalist, and human-friendly. It focuses on bits of information that have a particularly high value that are used again and again, as opposed to others that are only used when debugging a specific problem.
TRACE-level logging generally follows the same principles as DEBUG (and, for example, should also not be overloaded), but can be used to debug any problem. Additionally, some log messages may exhibit different levels of detail at the TRACE level compared to the DEBUG level.
Proper logging depends on experience using logs. If you notice anything that does not meet our stated goals, please let us know.
Confidential data
You can use logging at the DEBUG and TRACE levels to capture sensitive information. This is why request parameters
and headers are masked by default, and their full logging must be explicitly enabled via the enableLoggingRequestDetails
property for the DispatcherServlet
.
The following example shows how to do this using Java configuration:
public class MyInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return ... ;
}
@Override
protected Class<?>[] getServletConfigClasses() {
return ... ;
}
@Override
protected String[] getServletMappings() {
return ... ;
}
@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
registration.setInitParameter("enableLoggingRequestDetails", "true");
}
}
class MyInitializer : AbstractAnnotationConfigDispatcherServletInitializer() {
override fun getRootConfigClasses(): Array<Class<*>>? {
return ...
}
override fun getServletConfigClasses(): Array<Class<*>>? {
return ...
}
override fun getServletMappings(): Array<String> {
return ...
}
override fun customizeRegistration(registration: ServletRegistration.Dynamic) {
registration.setInitParameter("enableLoggingRequestDetails", "true")
}
}
GO TO FULL VERSION