Add support for logging groups

Provide a way for users to quickly group related loggers together for
easier configuration. The `loggers.group` property can be used to define
a group that can then be configured in the usual `loggers.level.<group>`
way.

Additionally, provide pre-defined groups for `web` and `sql.

Closes gh-14421
This commit is contained in:
Phillip Webb
2018-09-12 14:02:42 -07:00
parent 3ed9730b86
commit b32887b8eb
4 changed files with 136 additions and 16 deletions

View File

@@ -1731,6 +1731,46 @@ The following example shows potential logging settings in `application.propertie
[[boot-features-custom-log-groups]]
=== Log Groups
It's often useful to be able to group related loggers together so that they can all be
configured at the same time. For example, you might commonly change the logging levels for
_all_ Tomcat related loggers, but you can't easily remember to top level packages.
To help with this, Spring Boot allows you do define logging groups in your Spring
`Environment`. For example, here's how you could define a "`tomcat`" group by adding
it to your `appplication.properties`:
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----
logging.group.tomcat=org.apache.catalina, org.apache.coyote, org.apache.tomcat
----
Once defined, you can change the level for all the loggers in the group with a single
line:
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
----
logging.level.tomcat=TRACE
----
Spring Boot includes the following pre-defined logging groups that can be used
out-of-the-box:
[cols="1,4"]
|===
|Name |Loggers
|web
|`org.springframework.core.codec`, `org.springframework.http`, `org.springframework.web`
|sql
|`org.springframework.jdbc.core`, `org.hibernate.SQL`
|===
[[boot-features-custom-log-configuration]]
=== Custom Log Configuration
The various logging systems can be activated by including the appropriate libraries on