log4j does not create a log file in the system
<p>I am creating a Spring Boot Application in STS (Spring Tool Suite).</p>

<p>The problem occurs when trying to log using log4j. It does not create the log file in the system, though it does log on the console. I tried various methods given in the forum(including checking case-sensitivity, , but I think I am going wrong somewhere. An elaborate response would be really helpful.</p>

<p>I have a dependency in the <strong>pom.xml</strong> file for the log4j jar:-</p>

<pre><code>&lt;dependency&gt;
    &lt;groupId&gt;log4j&lt;/groupId&gt;
    &lt;artifactId&gt;log4j&lt;/artifactId&gt;
    &lt;version&gt;1.2.17&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<p>In my <strong>log4j.properties</strong> file, I am trying to have logs in console as well as a file </p>

<pre><code># Root logger option
log4j.rootLogger=ALL, stdout, file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

# Redirect log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C:\\log4j.log
log4j.appender.file.ImmediateFlush=true
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.FILE.layout.conversionPattern=%m%n
log4j.appender.file.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
</code></pre>

<p>Java controller where I want to log (<strong>IndexController.java</strong>)</p>

<pre><code>package com.project.Controller;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {

    final static Logger logger = Logger.getLogger(IndexController.class.getName());

    @RequestMapping("/")
    String index(Model model) {

        logger.info("in index");
        return "index";
    }
}
</code></pre>

<p>Please comment if you need any further details. Thanks</p>