title: Log4j - Have multiple appenders write to the same file with one that always logs
body: <p>I have a log4j appender defined like:</p>
  
  <pre><code>log4j.logger.com.example = DEBUG, filelog
  
  log4j.appender.filelog=org.apache.log4j.DailyRollingFileAppender
  log4j.appender.filelog.File=c:/app.log
  log4j.appender.filelog.layout=org.apache.log4j.PatternLayout
  log4j.appender.filelog.layout.ConversionPattern=%d | %m%n
  log4j.appender.filelog.DatePattern=.dd-MM-yyyy
  </code></pre>
  
  <p>In my class, I get the logger like:</p>
  
  <pre><code>Log logger = LogFactory.getLog(getClass());
  </code></pre>
  
  <p>This works properly.  I want to have a logger that always logs certain messages (not errors, but things like how long transactions took).  If I write these at DEBUG or INFO, I won't see them if the log level is changed.  I think I can accomplish this using another appender that writes to the same file.</p>
  
  <p>Is this possible to have two appenders write to the same file?  How would I get the logger instance where I want to use the normal debug appender and the transactional appender in the same class?  These messages won't all be in the same package, so I can't configure a certain package to always log.  Will I have to have these appenders write to different files, or can I retrieve them both in the code and have something like:</p>
  
  <pre><code>Log alwaysLogger = LogFactory.getLog(ALWAYS);
  alwaysLogger.debug("This message will always be written regardless of the level set on the filelog appender");
  </code></pre>
  
  <p><strong>Update</strong>
  I could write to two different log files if necessary, but how would I get the logger instance in my class?  I don't want to configure one package/class to always use one appender over the other as the classes will have to log information/error messages and the transactional "always" messages during a normal run.  Is there a way to accomplish what I need even if it write to two different log files?</p>