Provide Gradle example for using Log4j2

Closes gh-12729
This commit is contained in:
Andy Wilkinson 2018-06-21 11:57:38 +01:00
parent 8a0f0354df
commit 29e87257b4

View File

@ -1648,7 +1648,7 @@ instead. If you aren't using the starters then you need to provide `jcl-over-slf
(at least) in addition to Log4j 2.
The simplest path is probably through the starters, even though it requires some
jiggling with excludes, .e.g. in Maven:
jiggling with excludes. The following example shows how to set up the starters in Maven:
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
----
@ -1672,6 +1672,23 @@ jiggling with excludes, .e.g. in Maven:
</dependency>
----
And the following example shows one way to set up the starters in Gradle:
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]
----
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-starter-log4j2'
}
configurations {
all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
}
----
NOTE: The use of the Log4j starters gathers together the dependencies for common logging
requirements (e.g. including having Tomcat use `java.util.logging` but configuring the
output using Log4j 2). See the Actuator Log4j 2 samples for more detail and to see it in