1 Reply Latest reply on Apr 28, 2009 12:41 PM by Murat ALPAY

    logging details onto a file

    neelima chintala Newbie

      I am getting the logging details on the console of  my eclipse.But I want all log info to be collected onto a file..How can i direct them to a file.What r the configurations i need to change..Anyone help..
      Thanks in advance.

        • 1. Re: logging details onto a file
          Murat ALPAY Newbie

          check out : http://wiki.apache.org/logging-log4j/Log4jXmlFormat

          a log4j.xml like the following on the classpath will do it (from link above) :

          <?xml version="1.0" encoding="UTF-8" ?>
          <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
          <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
            <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> 
              <layout class="org.apache.log4j.PatternLayout"> 
                <!-- Pattern to output the caller's file name and line number -->
                <param name="ConversionPattern" value="%5p [%t] (%F:%L) - %m%n"/> 
            <appender name="R" class="org.apache.log4j.RollingFileAppender"> 
              <param name="file" value="example.log"/>
              <param name="MaxFileSize" value="100KB"/>
              <!-- Keep one backup file -->
              <param name="MaxBackupIndex" value="1"/>
              <layout class="org.apache.log4j.PatternLayout"> 
                <param name="ConversionPattern" value="%p %t %c - %m%n"/> 
            <logger name="com.mycompany.apackage.MyClass">
              <level value="info"/> 
              <priority value ="debug" /> 
              <appender-ref ref="stdout" /> 
              <appender-ref ref="R" />