title: Log4j seems not to work in Spring Boot
body: <p>I tried to add <code>Spring</code> and <code>Maven</code> to one of my existing project, and I find that no matter how I configure, the logging seems to be out of my control.</p>
  
  <p>I tried putting the <code>log4j.properties</code> in <code>src/main/java</code> and <code>src/main/resources</code>(Actually I am not sure where to put). </p>
  
  <p>But when I use <code>Log4j</code> to log, the log displays in the console only, though I configure it into a file. </p>
  
  <p>My <code>log4j.properties</code> is like:</p>
  
  <pre><code>log4j.rootLogger=DEBUG, A1 
  log4j.appender.A1=org.apache.log4j.FileAppender
  log4j.appender.A1.encoding=utf-8
  log4j.appender.A1.File=E:\Programminglog\debug.log 
  log4j.appender.A1.Threshold = DEBUG 
  log4j.appender.A1.Append=true
  log4j.appender.A1.layout=org.apache.log4j.PatternLayout
  log4j.appender.A1.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss}  [ %t:%r ] - [ %p ]  %m%n
  </code></pre>
  
  <p>I am not sure if I miss something or <code>Spring</code> overrides some settings, since I am new to <code>Maven</code> and <code>Spring</code>.</p>
  
  <p>PS: Before I add dependencies of <code>Log4j</code> in <code>pom</code>.xml,no compile errors though I use <code>org.apache.log4j.Logger</code> </p>
  
  <p>This is how my application.java looks like:</p>
  
  <pre><code>@Configuration
  @EnableAutoConfiguration
  @ComponentScan({"hello","wodinow.weixin.jaskey"})
  public class Application extends WebMvcConfigurerAdapter  {
  
      public static void main(String[] args) {
          ApplicationContext ctx = SpringApplication.run(Application.class, args);
  
          System.out.println("Let's inspect the beans provided by Spring Boot:");
  
          String[] beanNames = ctx.getBeanDefinitionNames();
          Arrays.sort(beanNames);
          for (String beanName : beanNames) {
              System.out.println(beanName);
          }
  
          LogUtil.info("Application Boots!");// here this line does not show in the file
      }
  
      @Bean
      public CommandService commandService(){
          return CommandService.getInstance();
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/KcFiC.jpg" alt="enter image description here"></p>