title: Log4j in SpringBoot
body: <p>I'm newbie to Spring Boot and working on a simple log4j demo using Spring Boot. I used the gradle project and have spring-boot-starter-web and groovy dependencies. Below is my log4j.properties file content. All I need is , when i execute the main program and use annotation @Log4J i must be able to save the log.perflog to a file in my local (windows).</p>
  
  <pre><code>log4j.rootLogger = WARN , stdout, cslLog
  
  log4j.logger.perfLog = WARN, perfLog
  log4j.additivity.perfLog = false
  
  log4j.appender.perfLog = org.apache.log4j.RollingFileAppender
  log4j.appender.perfLog.File = ${GRAILS_HOME}/logs/csl.log
  log4j.appender.perfLog.Append = true
  log4j.appender.perfLog.ImmediateFlush = true
  
  log4j.appender.perfLog.MaxFileSize=200MB
  log4j.appender.perfLog.MaxBackupIndex = 1
  </code></pre>
  
  <p>My sample groovy Class:</p>
  
  <pre><code>package sample.actuator.log4j
  
  import groovy.util.logging.Log4j;
  import org.apache.log4j.Logger;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @Log4j
  @RestController
  @EnableAutoConfiguration
  class HelloGroovy {
  
      static Logger perfLog = Logger.getLogger("perfLog")
  
      @RequestMapping("/logger")
      String logger() {
          log.info "created a new item named  identifier"
          log.error "created a new item named  identifier"
          log.warn "created a new item named  identifier"
  
          System.out.println("Test")
          perfLog.trace("Test")
          return "Logger Called."
  
      }
  
      static main(args) {
  
          SpringApplication.run(this, args)
      }
  
  }
  </code></pre>
  
  <p>All get is the first 3 lines print in the console and then "Test" , post that nothing shows up in the file i have mentioned in the log4j.properties.</p>
  
  <p>My build.gradle file</p>
  
  <pre><code>buildscript {
      repositories {
              maven {
                  url 'http://artifactory.myorg.com:8081/artifactory/plugins-release'
              }
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.5.RELEASE")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'idea'
  apply plugin: 'spring-boot'
  
  jar {
      baseName = 'log4jOwn'
  }
  
  repositories {
              maven {
                  url 'http://artifactory.myorg.com:8081/artifactory/plugins-release'
              }
      }
  
  dependencies {
      compile 'org.codehaus.groovy:groovy-all:2.3.3'
      compile 'org.springframework.boot:spring-boot-starter-web'
  
      testCompile("junit:junit")
  }
  
  task wrapper(type: Wrapper) {
      gradleVersion = '1.11'
  }
  </code></pre>