title: gradle spring boot starter-logging failing with Logback errors
body: <p>I have a spring-boot starter webapplication.  Recently I have been getting errors related to Logback being on the classpath.  Below is my current gradle file:</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.3.1.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
      classpath('io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE')
      classpath 'net.saliman:gradle-cobertura-plugin:2.3.0'
      }
  }
  
  apply plugin: 'groovy'
  apply plugin: 'spring-boot'
  apply plugin: 'io.spring.dependency-management'
  apply plugin: 'war'
  
  
  repositories {
      mavenCentral()
  }
  
  configurations {
      providedRuntime
  }
  
  configurations {
      all*.exclude module: 'spring-boot-starter-logging'
  }
  
  dependencies {
      compile 'com.github.groovy-wslite:groovy-wslite:1.1.2'
      compile('org.springframework.boot:spring-boot-starter-web') 
  
      compile("org.springframework.boot:spring-boot-starter-data-rest")
      compile("org.springframework.boot:spring-boot-starter-data-jpa") 
      compile('org.springframework.boot:spring-boot-starter-log4j')
      compile('org.codehaus.groovy:groovy')
      compile("org.apache.accumulo:accumulo-core:1.6.2") {
          exclude module: "slf4j-log4j12"
      }
  
      compile("com.h2database:h2")
  
      providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
      testCompile('org.springframework.boot:spring-boot-starter-test')
  
      testCompile 'com.github.groovy-wslite:groovy-wslite:1.1.2'
      testCompile 'org.codehaus.groovy:groovy-json:2.4.5'
      testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
      testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
      testCompile 'cglib:cglib-nodep:3.1'
  
  }
  
  tasks.withType(Test) {
      systemProperty 'spring.profiles.active', 'test'
  }
  </code></pre>
  
  <p>With this configuration, I <strong>can run the war or use bootRun</strong> to start the application.  However, <strong>my spring integration tests all fail</strong> with the error</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation
  </code></pre>
  
  <p>I have looked over the internet, specifically at these <a href="https://stackoverflow.com/questions/21764128/how-do-i-exclude-all-instances-of-a-transitive-dependency-when-using-gradle">stack</a> <a href="https://stackoverflow.com/questions/25538800/log4j-in-springboot">overflow</a> <a href="https://stackoverflow.com/questions/28734647/gradle-spring-boot-dependencies-are-not-excluding">questions</a> for a solution.  The questions and answers on those questions helped me be able to run the application by excluding Logback.  However the tests are still failing.  <a href="http://www.idanfridman.com/how-to-exclude-libraries-from-dependcies-using-gradle/" rel="nofollow noreferrer">This article</a>, in particular helped me ensure that logback was not in the dependency tree.  When I run</p>
  
  <pre><code>gradlew -q dependencies --configuration compile
  </code></pre>
  
  <p>and view the output, logback is nowhere to be found in the dependency tree anymore with the above build.gradle file.  However, running Spring integration tests like the one below fails with the error message pasted above:</p>
  
  <pre><code>@SpringApplicationConfiguration(classes = Application.class, initializers = ConfigFileApplicationContextInitializer.class)
  @WebIntegrationTest
  class CanaryIntegrationSpec extends Specification {
  @Value('${local.server.port}') int port
  
  def "when we call single test endpoint then we get a response back"() {
      when:
      ResponseEntity entity = new RestTemplate().getForEntity("http://localhost:$port/query/test", String.class)
  
      then:
      entity.statusCode == HttpStatus.OK
      entity.body == /{"hello":"world"}/
  }
  }
  </code></pre>
  
  <p>TL;DR: My configuration works for running the war, but all integration tests now fail.  How can I fix my configuration so that tests pass again?  </p>