title: Log4J 2 Lookup values are used in config before they are loaded/present
body: <p>I am using the SystemPropertiesLookup lookup to configure my Log4J2 configuration. The system properties get set as the first line in my main method. The problem is that, when Log4J loads the configuration, the main method is not yet called, and so, the system properties are not yet filled in.</p>
  
  <p>Here is my log4j2.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration status="WARN" packages="org.base"&gt;
      &lt;appenders&gt;
          &lt;Console name="Console" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout pattern="%highlight{%d [%c{1}] %-5level: %msg%n}{STYLE=Logback}"/&gt;
          &lt;/Console&gt;
  
          &lt;File name="AppLog" fileName="logs/app-${sys:MIGRATION_ENV:-UNKNOWN}-${sys:MIGRATION_TITLE:-UNKNOWN}.log" append="false"&gt;
              &lt;PatternLayout pattern="%d [%c{1}] %-5level: %msg%n"/&gt;
          &lt;/File&gt;
      &lt;/appenders&gt;
  
      &lt;loggers&gt;
          &lt;root level="error"&gt;
              &lt;appender-ref ref="Console" level="error"/&gt;
              &lt;appender-ref ref="AppLog" level="error"/&gt;
          &lt;/root&gt;
          &lt;logger name="org.base" level="debug" additivity="false"&gt;
              &lt;appender-ref ref="Console" level="debug"/&gt;
              &lt;appender-ref ref="AppLog" level="debug"/&gt;
          &lt;/logger&gt;
      &lt;/loggers&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The file will be called app-UNKNOWN-UNKNOWN because when Log4J fills it in, the properties are not yet available.</p>
  
  <p>Is there a way to make Log4J wait, preferrably without moving configuration to Java code?</p>
  
  <p>The properties must be set during runtime (the first line of the main method).</p>
  
  <p>A possible fix could be to only call <code>getLogger(..)</code> AFTER that method, instead of initializing it with the variable, but it doesn't really fit into my task.</p>