Skip to content

Commit c03d877

Browse files
committed
Improve logging.register-shutdown-hook docs
Update the "Logging" reference documentation with a section about shutting down the logging system. Closes gh-24507
1 parent 1b908ab commit c03d877

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

+19
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,25 @@ Spring Boot includes the following pre-defined logging groups that can be used o
19281928

19291929

19301930

1931+
[[boot-features-custom-log-configuration]]
1932+
=== Using a Log Shutdown Hook
1933+
In order to release logging resources it is usually a good idea to stop the logging system when your application terminates.
1934+
Unfortunately, there's no single way to do this that will work with all application types.
1935+
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.
1936+
For example, Logback offers http://logback.qos.ch/manual/loggingSeparation.html[context selectors] which allow each Logger to be created in its own context.
1937+
1938+
For simple "single jar" applications deployed in their own JVM, you can use the `logging.register-shutdown-hook` property.
1939+
Setting `logging.register-shutdown-hook` to `true` will register a shutdown hook that will trigger log system cleanup when the JVM exits.
1940+
1941+
You can set the property in your `application.properties` or `application.yaml` file:
1942+
1943+
[source,properties,indent=0,configprops]
1944+
----
1945+
logging.register-shutdown-hook=true
1946+
----
1947+
1948+
1949+
19311950
[[boot-features-custom-log-configuration]]
19321951
=== Custom Log Configuration
19331952
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)