Improve logging.register-shutdown-hook docs
Update the "Logging" reference documentation with a section about shutting down the logging system. Closes gh-24507
This commit is contained in:
parent
1b908ab9c8
commit
c03d8773e7
|
@ -1928,6 +1928,25 @@ Spring Boot includes the following pre-defined logging groups that can be used o
|
|||
|
||||
|
||||
|
||||
[[boot-features-custom-log-configuration]]
|
||||
=== Using a Log Shutdown Hook
|
||||
In order to release logging resources it is usually a good idea to stop the logging system when your application terminates.
|
||||
Unfortunately, there's no single way to do this that will work with all application types.
|
||||
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.
|
||||
For example, Logback offers http://logback.qos.ch/manual/loggingSeparation.html[context selectors] which allow each Logger to be created in its own context.
|
||||
|
||||
For simple "single jar" applications deployed in their own JVM, you can use the `logging.register-shutdown-hook` property.
|
||||
Setting `logging.register-shutdown-hook` to `true` will register a shutdown hook that will trigger log system cleanup when the JVM exits.
|
||||
|
||||
You can set the property in your `application.properties` or `application.yaml` file:
|
||||
|
||||
[source,properties,indent=0,configprops]
|
||||
----
|
||||
logging.register-shutdown-hook=true
|
||||
----
|
||||
|
||||
|
||||
|
||||
[[boot-features-custom-log-configuration]]
|
||||
=== Custom Log Configuration
|
||||
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[].
|
||||
|
|
Loading…
Reference in New Issue