title: How to get Log4j log file absolute path in Java?
body: <p>I am using Log4j to logging and log file path provided in Log4j.xml file. The web app will be deployed on weblogic server and log file is generating under home/JEE/servername/logs directory. Using java how to get this "../../logs/cast-arm.log" absolute path in Java?</p>
  
  <p>log4j.xml (src\main\resources\log4j.xml)</p>
  
  <pre><code>&lt;appender name="armFile" class="org.apache.log4j.RollingFileAppender"&gt;
      &lt;param name="append" value="true" /&gt;
      &lt;param name="maxFileSize" value="10MB" /&gt;
      &lt;param name="maxBackupIndex" value="100" /&gt;
      &lt;param name="file" value="../../logs/cast-arm.log" /&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
      &lt;param name="ConversionPattern"  value="%d{yyyy-MMM-dd HH:mm:ss,SSS} [%t] %c %x%n  %-5p %m%n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>File file = new File("../../logs");
  </code></pre>