mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Extract code snippets from logging.adoc
See gh-36175
This commit is contained in:
@@ -25,62 +25,7 @@ through the `enableLoggingRequestDetails` property on `DispatcherServlet`.
|
||||
|
||||
The following example shows how to do so by using Java configuration:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
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")
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
include-code::./MyInitializer[tag=snippet,indent=0]
|
||||
|
||||
|
||||
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.docs.web.webmvc.mvcservlet.mvcloggingsensitivedata;
|
||||
|
||||
import jakarta.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
// tag::snippet[]
|
||||
public class MyInitializer
|
||||
extends AbstractAnnotationConfigDispatcherServletInitializer {
|
||||
|
||||
// @fold:on
|
||||
@Override
|
||||
protected Class<?>[] getRootConfigClasses() {
|
||||
/**/throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getServletConfigClasses() {
|
||||
/**/throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getServletMappings() {
|
||||
/**/throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// @fold:off
|
||||
@Override
|
||||
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
|
||||
registration.setInitParameter("enableLoggingRequestDetails", "true");
|
||||
}
|
||||
|
||||
}
|
||||
// end::snippet[]
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.docs.web.webmvc.mvcservlet.mvcloggingsensitivedata
|
||||
|
||||
import jakarta.servlet.ServletRegistration
|
||||
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer
|
||||
|
||||
// tag::snippet[]
|
||||
class MyInitializer : AbstractAnnotationConfigDispatcherServletInitializer() {
|
||||
|
||||
// @fold:on
|
||||
override fun getRootConfigClasses(): Array<Class<*>>? {
|
||||
/**/TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getServletConfigClasses(): Array<Class<*>>? {
|
||||
/**/TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getServletMappings(): Array<String> {
|
||||
/**/TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
// @fold:off
|
||||
override fun customizeRegistration(registration: ServletRegistration.Dynamic) {
|
||||
registration.setInitParameter("enableLoggingRequestDetails", "true")
|
||||
}
|
||||
}
|
||||
// end::snippet[]
|
||||
Reference in New Issue
Block a user