Log4j2 - PatternLayout dependend on LogLevel
<p>Is it possible to define two different PatternLayouts and dependend on the application LogLevel it uses the first or the second one?</p>

<p>Example: </p>

<p>If i run my application with ERROR Level, which is the default, it should print the log statements like:</p>

<pre><code>$java -jar myApp.jar param1=value1

Error Message 1
Error Message 2
</code></pre>

<p>But if i run my application with INFO or DEBUG, it should print the log Statements like:</p>

<pre><code>$java -jar myApp.jar --debug param1=value1

DEBUG | 18.03.2016 11:04:43,412 1058 | Debug Message 1
DEBUG | 18.03.2016 11:04:43,412 1058 | Debug Message 2
INFO  | 18.03.2016 11:04:43,414 1060 | Info Message 1
ERROR | 18.03.2016 11:04:43,420 1066 | Error Message 1
ERROR | 18.03.2016 11:04:43,420 1066 | Error Message 2
</code></pre>

<p>Internally if the parameter --debug or --info is given, my app is switching the global LogLevel. The default is ERROR.</p>

<p>How should i configure my <a href="https://github.com/cecom/PACIFy/blob/develop/impl/src/main/resources/log4j2.xml" rel="nofollow">log4j2.xml</a> to accomplish this?? I could not find any solution. For reference my <a href="https://github.com/cecom/PACIFy/blob/develop/commandline/src/main/java/com/geewhiz/pacify/commandline/PacifyViaCommandline.java#L91" rel="nofollow">commandLine parser</a> and the <a href="https://github.com/cecom/PACIFy/blob/develop/common/src/main/java/com/geewhiz/pacify/utils/LoggingUtils.java" rel="nofollow">util class</a> where i switch the LogLevel at runtime.</p>