title: Log4j multiple classes with different loggers and one property file
body: <p>I have two classes <strong>A</strong> and <strong>B</strong>. I want to log class A to a.log and class B to b.log with a single log4j.properties in the root directory, my efforts so far:</p>
  
  <p>In class A:</p>
  
  <pre><code>private static final Logger l = Logger.getLogger("classa");
  </code></pre>
  
  <p>In class B:</p>
  
  <pre><code>private static final Logger l = Logger.getLogger("classb");
  </code></pre>
  
  <p>log4j.properties:</p>
  
  <pre><code>log4j.logger.classa=ALL,A1
  log4j.appender.A1=org.apache.log4j.RollingFileAppender
  log4j.appender.A1.append=false
  log4j.appender.A1.MaxBackupIndex=1
  log4j.appender.A1.file=a.log
  log4j.appender.A1.layout=org.apache.log4j.PatternLayout
  log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
  
  log4j.logger.classb=ALL,A2
  log4j.appender.A2=org.apache.log4j.RollingFileAppender
  log4j.appender.A2.append=false
  log4j.appender.A2.MaxBackupIndex=1
  log4j.appender.A2.file=b.log
  log4j.appender.A2.layout=org.apache.log4j.PatternLayout
  log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
  </code></pre>
  
  <p>Any ideas?</p>