title: How to add level to appender in manual code configuration in log4j2?
body: <p>From <a href="https://logging.apache.org/log4j/2.0/faq.html#config_sep_appender_level" rel="nofollow noreferrer">here</a></p>
  
  <blockquote>
    <p>You don’t need to declare separate loggers to achieve this. You can
    set the logging level on the AppenderRef element.</p>
  </blockquote>
  
  <p>And xml example (part):</p>
  
  <pre><code>&lt;Root level="trace"&gt;
    &lt;AppenderRef ref="file" level="DEBUG"/&gt;
    &lt;AppenderRef ref="STDOUT" level="INFO"/&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>But I can't find a way to do it when I create configuration myself. For example I have consoleAppenderBuilder and rootLoggerBuilder:</p>
  
  <pre><code>AppenderComponentBuilder consoleAppenderBuilder = builder
      .newAppender("Stdout", "CONSOLE")
      .addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
  
  RootLoggerComponentBuilder rootLoggerBuilder = builder
      .newRootLogger(Level.ERROR)
      .add(builder.newAppenderRef("Stdout"));
  </code></pre>
  
  <p>How to add console appender to root logger and define log level for appender. I am asking this because I want to add multiple appenders to root logger.</p>