title: log4j.properties file - multiple loggers in same class
body: <p>I would like to have two different <code>log4j</code> loggers in my application, and for there to be no "overlap" between the content they write to their respect logs. </p>
  
  <p>For example:</p>
  
  <ul>
  <li>Logger1 writes INFO events related to one set of system events</li>
  <li>Logger2 writes INFO events related to another set of system events</li>
  <li>No entry should appear in the log twice</li>
  </ul>
  
  <p>My log4j.properties is as follows:</p>
  
  <pre><code>log4j.rootLogger=DEBUG, stdout
  log4j.logger.org.apache=DEBUG, stdout
  log4j.logger.xdasLogger=DEBUG, xdas
  
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%m%n
  
  log4j.appender.xdas=org.apache.log4j.ConsoleAppender
  log4j.appender.xdas.layout=org.apache.log4j.PatternLayout
  log4j.appender.xdas.layout.ConversionPattern=%d %-5p %c - %m%n
  </code></pre>
  
  <p>My Java code is as follows:</p>
  
  <pre><code>public static void main(String[] args) {
      PropertyConfigurator.configure(Client.class
              .getResource("/log4j.properties"));
      xdasLogger = Logger.getLogger("xdasLogger");
      logger = Logger.getLogger(Client.class);
  
      logger.info("normal");
      xdasLogger.info("xdas");
  }
  </code></pre>
  
  <p>But my console output is as follows:</p>
  
  <pre><code>normal
  2012-06-28 09:52:44,580 INFO  xdasLogger - xdas
  xdas
  </code></pre>
  
  <p>Note that "xdas" is logged by both <code>logger</code> and <code>xdasLogger</code>, which is undesirable.</p>
  
  <p>Does anyone know what changes I need to put into my log4j.properties to change the console output to the following?</p>
  
  <pre><code>normal
  2012-06-28 09:52:44,580 INFO  xdasLogger - xdas
  </code></pre>
  
  <p><strong>Solution (taken from accepted answer):</strong></p>
  
  <pre><code>log4j.rootLogger=DEBUG, stdout
  log4j.logger.org.apache=DEBUG, stdout
  log4j.logger.xdasLogger=DEBUG, xdas
  
  log4j.additivity.org.apache=false
  log4j.additivity.xdasLogger=false
  
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%m%n
  
  log4j.appender.xdas=org.apache.log4j.ConsoleAppender
  log4j.appender.xdas.layout=org.apache.log4j.PatternLayout
  log4j.appender.xdas.layout.ConversionPattern=%d %-5p %c - %m%n
  </code></pre>