You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/02/22 14:53:15 UTC

cvs commit: jakarta-log4j/org/apache/log4j AppenderSkeleton.java DailyRollingFileAppender.java FileAppender.java WriterAppender.java

ceki        01/02/22 05:53:15

  Modified:    build    build.xml
               org/apache/log4j AppenderSkeleton.java
                        DailyRollingFileAppender.java FileAppender.java
                        WriterAppender.java
  Log:
  Improved docs. Corrected missing File otion error message in FileAppender.java
  
  Revision  Changes    Path
  1.10      +1 -1      jakarta-log4j/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/build/build.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- build.xml	2001/02/20 19:16:41	1.9
  +++ build.xml	2001/02/22 13:53:14	1.10
  @@ -258,8 +258,8 @@
   			 org.apache.log4j.varia,
   		         org.apache.log4j.xml,
   		         org.apache.log4j.xml.examples"
  -	   protected="true"				       
   	   version="true"
  +	   protected="true"
   	   author="true"
   	   use="true"		   
   	   overview="${docs}/overview.html"
  
  
  
  1.8       +6 -7      jakarta-log4j/org/apache/log4j/AppenderSkeleton.java
  
  Index: AppenderSkeleton.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/AppenderSkeleton.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AppenderSkeleton.java	2001/02/13 17:37:04	1.7
  +++ AppenderSkeleton.java	2001/02/22 13:53:14	1.8
  @@ -277,15 +277,14 @@
   
   
     /**
  -     Configurable Appenders should override this method if they admit
  -     additional options.
  -
        All classes derived from {@link AppenderSkeleton} admit the
  -     <b>Threshold</b> option, that is the value of the string constant
  -     {@link #THRESHOLD_OPTION}.
  +     <b>Threshold</b> option. The value of this option is a priority
  +     string, such as "DEBUG", "INFO" and so on.  All log events with
  +     lower priority than the threshold priority are ignored by the
  +     appender.  
   
  -     See {@link #setThreshold} method for the meaning of this option.
  -  */
  +     <p>Configurable Appenders should override this method if they
  +     admit additional options.  */
     public
     void setOption(String key, String value) {
       if(key.equalsIgnoreCase(THRESHOLD_OPTION)) {
  
  
  
  1.4       +103 -26   jakarta-log4j/org/apache/log4j/DailyRollingFileAppender.java
  
  Index: DailyRollingFileAppender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/DailyRollingFileAppender.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DailyRollingFileAppender.java	2001/02/21 22:28:13	1.3
  +++ DailyRollingFileAppender.java	2001/02/22 13:53:14	1.4
  @@ -28,29 +28,106 @@
   import org.apache.log4j.spi.ErrorCode;
   
   /**
  -   DailyRollingFileAppender extends FileAppender to use filenames formatted
  -   with date/time information. The filename is recomputed every day at
  -   midnight.  Note that the filename doesn't have to change every day,
  -   making it possible to have logfiles which are per-week or
  -   per-month.
  -
  -   The appender computes the proper filename using the formats
  -   specified in {@link SimpleDateFormat}. The format requires
  -   that most static text is enclosed in single quotes, which are
  -   removed. The examples below show how quotes are used to embed
  -   static information in the format.
  -
  -   Sample filenames:
  -
  -<code>
  -     Filename pattern                     Filename
  -     "'/logs/trace-'yyyy-MM-dd'.log'"     /logs/trace-2000-12-31.log
  -     "'/logs/trace-'yyyy-ww'.log'"        /logs/trace-2000-52.log
  -</code>
  +   DailyRollingFileAppender extends {@link FileAppender} so that the
  +   underlying file is rolled over at a user chosen frequency.
   
  +   <p>The rolling schedule is specified by the <b>DatePattern</b>
  +   option. This pattern should follow the {@link SimpleDateFormat}
  +   conventions. In particular, you <em>must</em> escape literal text
  +   within a pair of single quotes. A formatted version of the date
  +   pattern is used as the suffix for the rolled file name.
  +
  +   <p>For example, if the <b>File</b> option is set to
  +   <code>/foo/bar.log</code> and the <b>DatePattern</b> set to
  +   <code>'.'yyyy-MM-dd</code>, on 2001-02-16 at midnight, the logging
  +   file <code>/foo/bar.log</code> will be copied to
  +   <code>/foo/bar.log.2001-02-16</code> and logging for 2001-02-17
  +   will continue in <code>/foo/bar.log</code> until it is rolled over
  +   itself the next day.
  +   
  +   <p>Is is possible to specify monthly, weekly, half-daily, daily,
  +   hourly, or minutely rollover schedules.
  +
  +   <p><table border="1">
  +   <tr>
  +   <th>DatePatten</th> 
  +   <th>rollover schdule</th>
  +   <th>example</th>
  +
  +   <tr>
  +   <td><code>'.'yyyy-MM</code>   
  +   <td>Rollover at the beginning of each month</td>   
  +
  +   <td>Assuming the first day of the week is Sunday, at Sunday 00:00,
  +   March 25th, 2001, <code>/foo/bar.log</code> will be copied to
  +   <code>/foo/bar.log.2001-03</code>. Logging for the month of April
  +   will be output to <code>/foo/bar.log</code> until it is rolled over
  +   itself at the beginning of May.
  +
  +   <tr>
  +   <td><code>'.'yyyy-ww</code>   
  +   
  +   <td>Rollover at the first day of each week. The first day of the
  +   week depends on the locale.</td>
  +   
  +   <td>At midnight, on March 31st, 2001, <code>/foo/bar.log</code>
  +   will be copied to <code>/foo/bar.log.2001-08</code>. Logging for
  +   the 9th week of 2001 will be output to <code>/foo/bar.log</code>
  +   until it is rolled over the next week.
  +
  +   <tr>
  +   <td><code>'.'yyyy-MM-dd</code>   
  +   
  +   <td>Rollover at midnight each day.</td>
  +   
  +   <td>At midnight, on March 9th, 2001, <code>/foo/bar.log</code> will
  +   be copied to <code>/foo/bar.log.2001-03-08</code>. Logging for the
  +   9th day of March will be output to <code>/foo/bar.log</code> until
  +   it is rolled over the next day.
  +
  +   <tr>
  +   <td><code>'.'yyyy-MM-dd-a</code>   
  +   
  +   <td>Rollover at midnight and midday of each day.</td>
  +   
  +   <td>At noon, on March 9th, 2001, <code>/foo/bar.log</code> will be
  +   copied to <code>/foo/bar.log.2001-03-09-AM</code>. Logging for the
  +   afternoon of the 9th will be output to <code>/foo/bar.log</code>
  +   until it is rolled over the next morning, i.e at midnight 00:00.
  +
  +   <tr>
  +   <td><code>'.'yyyy-MM-dd-HH</code>   
  +   
  +   <td>Rollover at the top of every hour.</td>
  +   
  +   <td>At approximately 11:00,000, on March 9th, 2001,
  +   <code>/foo/bar.log</code> will be copied to
  +   <code>/foo/bar.log.2001-03-09-10</code>. Logging for the 11th hour
  +   of of the 9th of March will be output to <code>/foo/bar.log</code>
  +   until it is rolled over at the beginning of the next hour.
  +
  +
  +   <tr>
  +   <td><code>'.'yyyy-MM-dd-HH-mm</code>   
  +   
  +   <td>Rollover at the beginning of every minutue.</td>
  +   
  +   <td>At approximately 11:23,000, on March 9th, 2001,
  +   <code>/foo/bar.log</code> will be copied to
  +   <code>/foo/bar.log.2001-03-09-10-22</code>. Logging for the minutue
  +   of 11:23 (9th of March) will be output to
  +   <code>/foo/bar.log</code> untill it is rolled over the next minute.
  +      
  +   </table>
  +
  +   <p>Do not use the colon ":" character in anywhere in the
  +   <b>DatePattern</b> option. The text before the colon is interpeted
  +   as the protocol specificaion of a URL which is probably not what
  +   you want.
  +
  +
      @author Eirik Lygre
  -   @author Ceki G&uuml;lc&uuml;
  -*/
  +   @author Ceki G&uuml;lc&uuml; */
   public class DailyRollingFileAppender extends FileAppender {
   
   
  @@ -285,13 +362,13 @@
       case DailyRollingFileAppender.TOP_OF_MINUTE:
   	this.set(Calendar.SECOND, 0);
   	this.set(Calendar.MILLISECOND, 0);
  -	this.add(Calendar.MINUTE, +1); 
  +	this.add(Calendar.MINUTE, 1); 
   	break;
       case DailyRollingFileAppender.TOP_OF_HOUR:
   	this.set(Calendar.MINUTE, 0); 
   	this.set(Calendar.SECOND, 0);
   	this.set(Calendar.MILLISECOND, 0);
  -	this.add(Calendar.HOUR_OF_DAY, +1); 
  +	this.add(Calendar.HOUR_OF_DAY, 1); 
   	break;
       case DailyRollingFileAppender.HALF_DAY:
   	this.set(Calendar.MINUTE, 0); 
  @@ -302,7 +379,7 @@
   	  this.set(Calendar.HOUR_OF_DAY, 12);
   	} else {
   	  this.set(Calendar.HOUR_OF_DAY, 0);
  -	  this.add(Calendar.DAY_OF_MONTH, +1);       
  +	  this.add(Calendar.DAY_OF_MONTH, 1);       
   	}
   	break;
       case DailyRollingFileAppender.TOP_OF_DAY:
  @@ -310,7 +387,7 @@
   	this.set(Calendar.MINUTE, 0); 
   	this.set(Calendar.SECOND, 0);
   	this.set(Calendar.MILLISECOND, 0);
  -	this.add(Calendar.DATE, +1);       
  +	this.add(Calendar.DATE, 1);       
   	break;
       case DailyRollingFileAppender.TOP_OF_WEEK:
   	this.set(Calendar.DAY_OF_WEEK, getFirstDayOfWeek());
  @@ -324,7 +401,7 @@
   	this.set(Calendar.HOUR_OF_DAY, 0);
   	this.set(Calendar.SECOND, 0);
   	this.set(Calendar.MILLISECOND, 0);
  -	this.add(Calendar.MONTH, +1); 
  +	this.add(Calendar.MONTH, 1); 
   	break;
       default:
   	throw new IllegalStateException("Unknown periodicity type.");
  
  
  
  1.14      +11 -7     jakarta-log4j/org/apache/log4j/FileAppender.java
  
  Index: FileAppender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/FileAppender.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FileAppender.java	2001/02/21 22:28:14	1.13
  +++ FileAppender.java	2001/02/22 13:53:14	1.14
  @@ -161,7 +161,9 @@
   			   e, ErrorCode.FILE_OPEN_FAILURE);
         }
       } else {
  -      LogLog.error("Filename option not set for appender ["+name+"].");
  +      //LogLog.error("File option not set for appender ["+name+"].");
  +      LogLog.warn("File option not set for appender ["+name+"].");
  +      LogLog.warn("Are you using FileAppender instead of ConsoleAppender?");
       }
     }
   
  @@ -253,15 +255,17 @@
        Set FileAppender specific options.
             
        The recognized options are <b>File</b> and <b>Append</b>,
  -     i.e. the values of the string constants {@link #FILE_OPTION} and
  -     respectively {@link #APPEND_OPTION}. The options of the super
  -     class {@link WriterAppender} are also recognized.
  +     i.e. the values of the string constants. The options of the super
  +     class {@link WriterAppender} are also recognized. See in
  +     particular the <b>Threshold</b> option on {@link
  +     AppenderSkeleton}.
   
        <p>The <b>File</b> option takes a string value which should be
  -     one of the strings "System.out" or "System.err" or the name of a
  -     file. 
  +     the name of the file to append to. Special values "System.out" or
  +     "System.err" are interpreted as the standard out and standard
  +     error streams.
   
  -     <font color="#FF0044"><b>Note that the "System.out" or "System.err"
  +     <font color="#DD0044"><b>Note that the "System.out" or "System.err"
        options are deprecated. Use {@link ConsoleAppender}
        instead.</b></font>
   
  
  
  
  1.6       +12 -3     jakarta-log4j/org/apache/log4j/WriterAppender.java
  
  Index: WriterAppender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/org/apache/log4j/WriterAppender.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WriterAppender.java	2001/02/21 22:28:14	1.5
  +++ WriterAppender.java	2001/02/22 13:53:14	1.6
  @@ -163,11 +163,13 @@
   
   
     /**
  -     Will close this appender. The underlying stream or writer is not closed.
  +     Close this appender instance. The underlying stream or writer is
  +     also closed.
  +     
  +     <p>Closed appenders cannot be reused.
   
        @see #setWriter
  -     @since 0.8.4
  -  */
  +     @since 0.8.4 */
     public
     synchronized
     void close() {
  @@ -335,6 +337,10 @@
       this.tp = null;    
     }
   
  +
  +  /**
  +     Write a footer as produced by the embedded layout's {@link
  +     Layout#getFooter} method.  */
     protected
     void writeFooter() {
       if(layout != null) {
  @@ -344,6 +350,9 @@
       }
     }
   
  +/**
  +     Write a header as produced by the embedded layout's {@link
  +     Layout#getHeader} method.  */
     protected 
     void writeHeader() {
       if(layout != null) {