title: Log4j2 not logging to graylog server properly
body: <p>Right now I am trying use log4j2 to log everything that has a level of I<strong>NFO or higher</strong> (WARN, ERROR, AND FATAL) to my <strong>server</strong> and anything that has a level of <strong>INFO</strong> to my <strong>console</strong>. I am able to log things to my console, however, I am having an issue logging the correct levels to the server properly. </p>
  
  <p>Here is what I have tried so far:</p>
  
  <p>Java</p>
  
  <pre><code>import java.time.Instant;
  
  import org.apache.log4j.PropertyConfigurator;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  
  public class App {
      private static final Logger log4j = LogManager.getLogger(App.class.getName());
  
      public static void main(String[] args) {
          try {
              String log4jConfPath = "src/main/resources/log4j2.xml";
              PropertyConfigurator.configure(log4jConfPath);
              log4j.info("this is a testmessage " + Instant.now().toString());
          }
          catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="trace" packages="org.graylog2.log4j2"&gt;
  
      &lt;Properties&gt;
          &lt;Property name="default_pattern"&gt;%d{MM/dd/yyyy hh:mm:ss} %5p %c{1} - %m%n
          &lt;/Property&gt;
      &lt;/Properties&gt;
  
      &lt;Appenders&gt;
          &lt;Console name="console" target="SYSTEM_OUT"&gt;
              &lt;PatternLayout pattern="${default_pattern}" /&gt;
          &lt;/Console&gt;
          &lt;GELF name="gelfAppender" server="graylog.x.something.com"
              hostName="some.host" port="12201"&gt;
              &lt;PatternLayout pattern="%d{dd MMM yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n" /&gt;
              &lt;KeyValuePair key="extractStacktrace" value="true" /&gt;
              &lt;KeyValuePair key="addExtendedInformation" value="true" /&gt;
              &lt;KeyValuePair key="facility" value="gelf-java" /&gt;
              &lt;KeyValuePair key="environment" value="TEST" /&gt;
              &lt;KeyValuePair key="application" value="MyApp" /&gt;
              &lt;KeyValuePair key="additionalFields" value="{'environment': 'TEST', 'application': 'MyAPP'}" /&gt;
          &lt;/GELF&gt;
      &lt;/Appenders&gt;
  
      &lt;Loggers&gt;
          &lt;Root level="error"&gt;
              &lt;AppenderRef ref="gelfAppender" /&gt;
              &lt;AppenderRef ref="console" /&gt;
          &lt;/Root&gt;
          &lt;Root level="info"&gt;
              &lt;AppenderRef ref="gelfAppender" /&gt;
              &lt;AppenderRef ref="console" /&gt;
  
          &lt;/Root&gt;
      &lt;/Loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>The above code does not output what I want, which is to have <strong>INFO</strong> level output to the <strong>console</strong> and <strong>INFO Levels and up</strong> output to the <strong>server</strong>.</p>
  
  <p>Instead, I am able to output: EVERYTHING (Trace) to console and INFO to the server.</p>
  
  <p>I have messed around with the XML file a little bit and I noticed that when I change</p>
  
  <pre><code>status="trace"
  </code></pre>
  
  <p>to </p>
  
  <pre><code>status="off"
  </code></pre>
  
  <p>it logs only INFO to the console, but nothing to the server.</p>
  
  <p>Lastly, and probably the most odd  thing of all, if I remove </p>
  
  <pre><code>Instant.now().toString()
  </code></pre>
  
  <p>from my print statement, then nothing will be logged to the server, regardless of the status (if it's TRACE or OFF), but it still logs to the console.
  I thought it had something to do with the pattern layout of my GELF appender, so I changed</p>
  
  <pre><code>&lt;PatternLayout pattern="%d{dd MMM yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n" /&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;PatternLayout pattern="${default_pattern}" /&gt;
  </code></pre>
  
  <p>but that did not change the output...</p>
  
  <p>Here are my current dependencies: </p>
  
  <p><a href="https://i.stack.imgur.com/FhA8r.png" rel="nofollow"><img src="https://i.stack.imgur.com/FhA8r.png" alt="enter image description here"></a></p>
  
  <p>In short, I just want to log levels of INFO to my console and levels of INFO or higher to my server.</p>