title: Log4J change File path dynamically
body: <p>I want to change the path and file name of my log4j logfile dynamically.</p>
  
  <p>I have read a lot of pages and nearly every tell me that I should use system properties like here:
  <a href="https://stackoverflow.com/questions/7006476/how-to-change-the-log4j-log-file-dynamically">how to change the log4j log file dynamically?</a></p>
  
  <p>So my log4j.properties file looks like this:</p>
  
  <pre><code>log4j.logger.JDBC_LOGGER=INFO,jdbcTests
  log4j.additivity.JDBC_LOGGER = false
  
  log4j.appender.jdbcTests=org.apache.log4j.FileAppender
  log4j.appender.jdbcTests.File=${my.log}
  log4j.appender.jdbcTests.layout=org.apache.log4j.PatternLayout
  log4j.appender.jdbcTests.append = false
  log4j.appender.jdbcTests.layout.ConversionPattern=%d{yyyy mm dd HH:mm:ss} %5p %C:Line %L - %m%n
  </code></pre>
  
  <p>In my main method I am going to set my new system property:</p>
  
  <pre><code>System.setProperty("{my.log", "C:/logfile.log");
  </code></pre>
  
  <p>But I just get an error:</p>
  
  <pre><code>log4j:ERROR setFile(null,false) call failed.
  java.io.FileNotFoundException: 
      at java.io.FileOutputStream.open(Native Method)....
  </code></pre>
  
  <p>And when I try to read my set system property with:</p>
  
  <pre><code>System.out.println(System.getProperty("my.log"));
  </code></pre>
  
  <p>it return null.
  What do I do wrong?</p>