title: Gradle | Spring boot dependencies are not excluding
body: <p>I'm trying to get log4j to work in a project that I'm working on. I added the relevant log4j dependencies in build.gradle and excluded the Spring boot starter logging so it can work. </p>
  
  <p>This worked fine when I used Maven as the build tool, but once I switched to Gradle it's not working at all (excepts the logging from Spring boot starter). Here are the dependencies in my build.gradle </p>
  
  <pre><code>dependencies {
      compile('org.springframework.boot:spring-boot-starter-data-jpa')
      compile('org.springframework.boot:spring-boot-starter-web'){
          exclude module: 'org.springframework.boot:spring-boot-starter-logging'
      }
      compile('org.springframework.boot:spring-boot-starter-log4j')
      compile('org.springframework.boot:spring-boot-starter-data-rest')
      compile('org.springframework.boot:spring-boot-starter-actuator')
      compile('org.postgresql:postgresql:9.3-1101-jdbc41')
      compile('org.scala-lang:scala-library:2.10.4')
      testCompile('org.springframework.boot:spring-boot-starter-test') {
          exclude module: 'commons-logging'
      }
      providedCompile('org.springframework.boot:spring-boot-starter-tomcat')
  }
  </code></pre>
  
  <p>But as you can clearly see in the dependency tree the <code>spring-boot-starter-logging</code> is still there. I'm guessing that this is the issue why the logging isn't working.</p>
  
  <p>Here's the dependency tree:</p>
  
  <pre><code>+--- org.springframework.boot:spring-boot-starter-data-jpa: -&gt; 1.2.1.RELEASE
  |    +--- org.springframework.boot:spring-boot-starter:1.2.1.RELEASE
  |    |    +--- org.springframework.boot:spring-boot:1.2.1.RELEASE
  |    |    |    +--- org.springframework:spring-core:4.1.4.RELEASE
  |    |    |    \--- org.springframework:spring-context:4.1.4.RELEASE
  |    |    |         +--- org.springframework:spring-aop:4.1.4.RELEASE
  |    |    |         |    +--- aopalliance:aopalliance:1.0
  |    |    |         |    +--- org.springframework:spring-beans:4.1.4.RELEASE
  |    |    |         |    |    \--- org.springframework:spring-core:4.1.4.RELEASE
  |    |    |         |    \--- org.springframework:spring-core:4.1.4.RELEASE
  |    |    |         +--- org.springframework:spring-beans:4.1.4.RELEASE (*)
  |    |    |         +--- org.springframework:spring-core:4.1.4.RELEASE
  |    |    |         \--- org.springframework:spring-expression:4.1.4.RELEASE
  |    |    |              \--- org.springframework:spring-core:4.1.4.RELEASE
  |    |    +--- org.springframework.boot:spring-boot-autoconfigure:1.2.1.RELEASE
  |    |    |    \--- org.springframework.boot:spring-boot:1.2.1.RELEASE (*)
  |    |    +--- org.springframework.boot:spring-boot-starter-logging:1.2.1.RELEASE
  </code></pre>
  
  <p>Here's my log4j.properties file</p>
  
  <pre><code>log4j.rootLogger=INFO, fileout, CONSOLE
  PID=????
  LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] log4j%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n
  
  
  # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
  log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
  log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
  log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN}
  
  # Log4j configurations for with file appender
  log4j.category.org.hibernate.validator.internal.util.Version=WARN
  log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN
  log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN
  log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR
  
  log4j.appender.fileout=org.apache.log4j.RollingFileAppender
  log4j.appender.fileout.File=sampleLog.log
  log4j.appender.fileout.MaxFileSize=1024KB
  log4j.appender.fileout.MaxBackupIndex=1
  log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
  log4j.appender.fileout.layout.conversionPattern=${LOG_PATTERN}
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I managed to fix the exclusion of jar file dependency. But the logging is still not working, log4j.properties is also in the WAR distribution under classes. </p>
  
  <p><strong>UPDATE 02</strong></p>
  
  <p>It worked issue is with the my IDE (STS)</p>