title: how to write to a text file using to log4j?
body: <p>I'm wondering how to convert the following code to output those lines into a text file, and not to standard output:</p>
  
  <pre><code>import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator;
  
  public class HelloWorld {
  
      static final Logger logger = Logger.getLogger(HelloWorld.class);
  
      public static void main(String[] args) {
          PropertyConfigurator.configure("log4j.properties");
          logger.debug("Sample debug message");
          logger.info("Sample info message");
          logger.warn("Sample warn message");
          logger.error("Sample error message");
          logger.fatal("Sample fatal message");
      }
  }
  </code></pre>
  
  <p>The properties file is :</p>
  
  <pre><code>log4j.rootLogger=DEBUG, CA
  log4j.appender.CA=org.apache.log4j.ConsoleAppender
  log4j.appender.CA.layout=org.apache.log4j.PatternLayout
  log4j.appender.FA.layout.ConversionPattern=%m%n
  </code></pre>
  
  <p>Thanks.</p>