title: Not able to create a log file using log4j2
body: <p>I am relatively new to log4j2. I am trying to create a log file using log4j2 but it is not getting created. Any help is appreciated. Thanks in advance.</p>
  
  <p><strong>log4j.xml Configuration File(below):</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE project&gt;
  &lt;Configuration xmlns="http://logging.apache.org/log4j/2.0/config"&gt;
      &lt;Properties&gt;
          &lt;Property name="basePath"&gt;../resources/logs&lt;/Property&gt;
      &lt;/Properties&gt;
      &lt;Appenders&gt;
          &lt;!-- File Appender --&gt;
          &lt;File name="FILE" fileName="${basePath}/logfile.log" append="true"&gt;
              &lt;PatternLayout
                  pattern="[%-5p][%d{dd-MMM-yyyy HH:mm:ss a}] %C{0}.%M:(%L) - %m%n" /&gt;
          &lt;/File&gt;
          &lt;!-- Console Appender --&gt;
          &lt;Console name="STDOUT" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout
                  pattern="[%-5p][%d{dd-MMM-yyyy HH:mm:ss a}] %C{0}.%M:(%L) - %m%n" /&gt;
          &lt;/Console&gt;
      &lt;/Appenders&gt;
      &lt;Loggers&gt;
          &lt;Logger name="log" level="all" /&gt;
          &lt;Root level="all"&gt;
              &lt;AppenderRef ref="FILE" level="all" /&gt;
              &lt;AppenderRef ref="STDOUT" level="all" /&gt;
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p><strong>Project Folder Structure(below):</strong></p>
  
  <p><a href="https://i.stack.imgur.com/fnhzb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fnhzb.png" alt="enter image description here"></a></p>
  
  <p><strong>My Java Code(below):</strong></p>
  
  <pre><code>import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  
  public class Demo {
  
      public static Logger log;
  
      public static void main(String[] args) {
          System.err.println("Start");
  
          System.setProperty("log4j.configurationFile", "./resources/config/logger/log4j2.xml");
          log = LogManager.getLogger(Demo.class.getName());
  
          System.err.println("Initialisied Logger");
          log.trace("TRACE");
          log.debug("DEBUG");
          log.info("INFO");
          log.warn("WARN");
          log.error("ERROR");
          log.fatal("FATAL");
  
          System.err.println("END");
      }
  
  }
  </code></pre>
  
  <p><strong>Maven Dependency(below):</strong></p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
      &lt;version&gt;2.10.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;
      &lt;version&gt;2.10.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>Console Outout(below):</strong></p>
  
  <pre><code>Start
  Initialisied Logger
  [TRACE][28-Feb-2018 14:45:11 PM] Demo.main:(17) - TRACE
  [DEBUG][28-Feb-2018 14:45:11 PM] Demo.main:(18) - DEBUG
  [INFO ][28-Feb-2018 14:45:11 PM] Demo.main:(19) - INFO
  [WARN ][28-Feb-2018 14:45:11 PM] Demo.main:(20) - WARN
  [ERROR][28-Feb-2018 14:45:11 PM] Demo.main:(21) - ERROR
  [FATAL][28-Feb-2018 14:45:11 PM] Demo.main:(22) - FATAL
  END
  </code></pre>