You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc
+19
Original file line number
Diff line number
Diff line change
@@ -1928,6 +1928,25 @@ Spring Boot includes the following pre-defined logging groups that can be used o
1928
1928
1929
1929
1930
1930
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
+
1931
1950
[[boot-features-custom-log-configuration]]
1932
1951
=== Custom Log Configuration
1933
1952
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