Skip to content

Commit 2d05652

Browse files
committed
Merge branch '2.3.x' into 2.4.x
Closes gh-25044
2 parents ca9b612 + c03d877 commit 2d05652

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc

+20
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,26 @@ Spring Boot includes the following pre-defined logging groups that can be used o
22152215

22162216

22172217

2218+
[[boot-features-custom-log-configuration]]
2219+
=== Using a Log Shutdown Hook
2220+
In order to release logging resources it is usually a good idea to stop the logging system when your application terminates.
2221+
Unfortunately, there's no single way to do this that will work with all application types.
2222+
If your application has complex context hierarchies or is deployed as a war file, you'll need to investigate the options provided directly by the underlying logging system.
2223+
For example, Logback offers http://logback.qos.ch/manual/loggingSeparation.html[context selectors] which allow each Logger to be created in its own context.
2224+
2225+
For simple "single jar" applications deployed in their own JVM, you can use the `logging.register-shutdown-hook` property.
2226+
Setting `logging.register-shutdown-hook` to `true` will register a shutdown hook that will trigger log system cleanup when the JVM exits.
2227+
2228+
You can set the property in your `application.properties` or `application.yaml` file:
2229+
2230+
[source,yaml,indent=0,configprops,configblocks]
2231+
----
2232+
logging:
2233+
register-shutdown-hook: true
2234+
----
2235+
2236+
2237+
22182238
[[boot-features-custom-log-configuration]]
22192239
=== Custom Log Configuration
22202240
The various logging systems can be activated by including the appropriate libraries on the classpath and can be further customized by providing a suitable configuration file in the root of the classpath or in a location specified by the following Spring `Environment` property: configprop:logging.config[].

0 commit comments

Comments
 (0)