From 29e87257b45f3b95624ae87a2dcb3ad175e64e66 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 21 Jun 2018 11:57:38 +0100 Subject: [PATCH] Provide Gradle example for using Log4j2 Closes gh-12729 --- spring-boot-docs/src/main/asciidoc/howto.adoc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index e0f983cf05..e4be20046f 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -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: ---- +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