logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: logging-log4j/src/java/org/apache/log4j/xml DOMConfigurator.java
Date Thu, 06 Jan 2005 17:03:12 GMT
ceki        2005/01/06 09:03:12

  Modified:    src/java/org/apache/log4j/rolling
                        FixedWindowRollingPolicy.java
                        TimeBasedRollingPolicy.java RollingPolicyBase.java
               src/java/org/apache/log4j/db ConnectionSource.java
                        JNDIConnectionSource.java
                        DataSourceConnectionSource.java
                        DriverManagerConnectionSource.java
                        ConnectionSourceSkeleton.java
               src/java/org/apache/log4j/helpers
                        RelativeTimeDateFormat.java Constants.java
               src/java/org/apache/log4j/rolling/helper Util.java
               src/java/org/apache/log4j/joran/util JoranDocument.java
               tests/src/java/org/apache/log4j MinimumTest.java
               tests/src/java/org/apache/log4j/pattern
                        CachedDateFormatTest.java
               src/java/org/apache/log4j TTCCLayout.java
                        AppenderSkeleton.java WriterAppender.java
                        Appender.java FileAppender.java
               src/java/org/apache/log4j/pattern DatePatternConverter.java
                        PatternParser.java
               src/java/org/apache/log4j/chainsaw
                        TableColorizingRenderer.java LogPanel.java
               src/java/org/apache/log4j/net MulticastAppender.java
                        SocketAppender.java JMSAppender.java
                        UDPAppender.java
               tests    build.xml
               src/java/org/apache/log4j/xml DOMConfigurator.java
  Removed:     src/java/org/apache/log4j/helpers DateLayout.java
                        QuietWriter.java CountingQuietWriter.java
                        OnlyOnceErrorHandler.java
                        AbsoluteTimeDateFormat.java ISO8601DateFormat.java
                        DateTimeDateFormat.java
               src/java/org/apache/log4j/varia FallbackErrorHandler.java
               src/java/org/apache/log4j/spi ErrorCode.java
                        ErrorHandler.java
  Log:
  - Removed ErrrorHandler and derived classes.
  
    Since log4j components can use log4j itself to log messages, and since ErrorHandler code was used to log
    one and only one message, it is cleaner to have Appender implementation be responsible for their error conditions.
  
  - Removed the various DateFormat classes in o.a.l.helpers. Referent classes have been updated.
  
  Revision  Changes    Path
  1.6       +6 -2      logging-log4j/src/java/org/apache/log4j/rolling/FixedWindowRollingPolicy.java
  
  Index: FixedWindowRollingPolicy.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/FixedWindowRollingPolicy.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FixedWindowRollingPolicy.java	4 Jan 2005 19:42:10 -0000	1.5
  +++ FixedWindowRollingPolicy.java	6 Jan 2005 17:03:10 -0000	1.6
  @@ -64,6 +64,7 @@
       "See also http://logging.apache.org/log4j/codes.html#tbr_fnp_not_set";
     int maxIndex;
     int minIndex;
  +  Util util = new Util();
     
     /**
      * It's almost always a bad idea to have a large window size, say over 12. 
  @@ -77,6 +78,9 @@
     }
   
     public void activateOptions() {
  +    // set the LR for our utility object
  +    util.setLoggerRepository(this.repository);
  +    
       if (fileNamePatternStr != null) {
         fileNamePattern = new FileNamePattern(fileNamePatternStr);
         determineCompressionMode();
  @@ -132,7 +136,7 @@
   	  File toRename = new File(toRenameStr);
   	  // no point in trying to rename an inexistent file
   	  if(toRename.exists()) {
  -	      Util.rename(toRenameStr, fileNamePattern.convert(i + 1));
  +	      util.rename(toRenameStr, fileNamePattern.convert(i + 1));
   	  } else {
   	      getLogger().info("Skipping rollover for inexistent file {}", toRenameStr); 
             }
  @@ -142,7 +146,7 @@
         //move active file name to min
         switch (compressionMode) {
         case Compress.NONE:
  -          Util.rename(activeFileName, fileNamePattern.convert(minIndex));
  +          util.rename(activeFileName, fileNamePattern.convert(minIndex));
             break;
         case Compress.GZ:
             Compress.GZCompress(activeFileName, fileNamePattern.convert(minIndex));
  
  
  
  1.17      +6 -3      logging-log4j/src/java/org/apache/log4j/rolling/TimeBasedRollingPolicy.java
  
  Index: TimeBasedRollingPolicy.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/TimeBasedRollingPolicy.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TimeBasedRollingPolicy.java	14 Dec 2004 20:27:12 -0000	1.16
  +++ TimeBasedRollingPolicy.java	6 Jan 2005 17:03:10 -0000	1.17
  @@ -134,8 +134,7 @@
    * @author Ceki Gülcü
    * @since 1.3
    */
  -public class TimeBasedRollingPolicy extends RollingPolicyBase
  -  implements TriggeringPolicy {
  +public class TimeBasedRollingPolicy extends RollingPolicyBase implements TriggeringPolicy {
     static final String FNP_NOT_SET =
       "The FileNamePattern option must be set before using TimeBasedRollingPolicy. ";
     static final String SEE_FNP_NOT_SET =
  @@ -145,8 +144,12 @@
     Date lastCheck = new Date();
     String elapsedPeriodsFileName;
     FileNamePattern activeFileNamePattern;
  +  Util util = new Util();
     
     public void activateOptions() {
  +    // set the LR for our utility object
  +    util.setLoggerRepository(this.repository);
  +    
       // find out period from the filename pattern
       if (fileNamePatternStr != null) {
         fileNamePattern = new FileNamePattern(fileNamePatternStr);
  @@ -219,7 +222,7 @@
       } else {
         switch (compressionMode) {
         case Compress.NONE:
  -        Util.rename(activeFileName, elapsedPeriodsFileName);
  +        util.rename(activeFileName, elapsedPeriodsFileName);
           break;
         case Compress.GZ:
           getLogger().debug("GZIP compressing [[}]", elapsedPeriodsFileName);
  
  
  
  1.2       +2 -16     logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicyBase.java
  
  Index: RollingPolicyBase.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/RollingPolicyBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RollingPolicyBase.java	8 Dec 2004 21:21:32 -0000	1.1
  +++ RollingPolicyBase.java	6 Jan 2005 17:03:10 -0000	1.2
  @@ -16,10 +16,9 @@
   
   package org.apache.log4j.rolling;
   
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Logger;
   import org.apache.log4j.rolling.helper.Compress;
   import org.apache.log4j.rolling.helper.FileNamePattern;
  +import org.apache.log4j.spi.ComponentBase;
   
   
   /**
  @@ -30,12 +29,11 @@
    * @author Ceki Gülcü
    * @since 1.3
    */
  -public abstract class RollingPolicyBase implements RollingPolicy {
  +public abstract class RollingPolicyBase extends ComponentBase implements RollingPolicy {
     protected int compressionMode = Compress.NONE;
     protected FileNamePattern fileNamePattern;
     protected String fileNamePatternStr;
     protected String activeFileName;
  -  private Logger logger;
   
     /*
      * @see org.apache.log4j.spi.OptionHandler#activateOptions()
  @@ -76,17 +74,5 @@
      */
     public void setActiveFileName(String afn) {
       activeFileName = afn;
  -  }
  -
  -  /**
  -   * Return an instance specific logger to be used by the policy itself.
  -   *
  -   * @return instance specific logger
  -   */
  -  protected Logger getLogger() {
  -    if (logger == null) {
  -      logger = LogManager.getLogger(this.getClass().getName());
  -    }
  -    return logger;
     }
   }
  
  
  
  1.10      +0 -8      logging-log4j/src/java/org/apache/log4j/db/ConnectionSource.java
  
  Index: ConnectionSource.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/ConnectionSource.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ConnectionSource.java	4 Jan 2005 12:51:15 -0000	1.9
  +++ ConnectionSource.java	6 Jan 2005 17:03:10 -0000	1.10
  @@ -17,7 +17,6 @@
   package org.apache.log4j.db;
   
   import org.apache.log4j.spi.Component;
  -import org.apache.log4j.spi.ErrorHandler;
   import org.apache.log4j.spi.OptionHandler;
   
   import java.sql.Connection;
  @@ -49,13 +48,6 @@
      */
     Connection getConnection() throws SQLException;
   
  -  /**
  -   *  Set the error handler.
  -   *
  -   *  @param errorHandler  the new error handler
  -   */
  -  void setErrorHandler(ErrorHandler errorHandler);
  -  
     /**
      * Get the SQL dialect that should be used for this connection. Note that the
      * dialect is not needed if the JDBC driver supports the getGeneratedKeys 
  
  
  
  1.9       +4 -11     logging-log4j/src/java/org/apache/log4j/db/JNDIConnectionSource.java
  
  Index: JNDIConnectionSource.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/JNDIConnectionSource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JNDIConnectionSource.java	20 Nov 2004 12:47:06 -0000	1.8
  +++ JNDIConnectionSource.java	6 Jan 2005 17:03:10 -0000	1.9
  @@ -71,8 +71,8 @@
      * @see org.apache.log4j.spi.OptionHandler#activateOptions()
      */
     public void activateOptions() {
  -    if (jndiLocation == null && errorHandler != null) {
  -      errorHandler.error("No JNDI location specified for JNDIConnectionSource.");
  +    if (jndiLocation == null) {
  +      getLogger().error("No JNDI location specified for JNDIConnectionSource.");
       }
       
       discoverConnnectionProperties();
  @@ -96,17 +96,10 @@
           conn = dataSource.getConnection(user, password);
         }
       } catch (final NamingException ne) {
  -      if (errorHandler != null) {
  -        errorHandler.error(ne.getMessage(), ne, 0);
  -      }
  -
  -      getLogger().error("Error while getting data source", ne);
  +         getLogger().error("Error while getting data source", ne);
         throw new SQLException("NamingException while looking up DataSource: " + ne.getMessage());
       } catch (final ClassCastException cce) {
  -      if (errorHandler != null) {
  -        errorHandler.error(cce.getMessage(), cce, 0);
  -      }
  -
  +      getLogger().error("ClassCastException while looking up DataSource.", cce);
         throw new SQLException("ClassCastException while looking up DataSource: " + cce.getMessage());
       }
   
  
  
  
  1.9       +1 -8      logging-log4j/src/java/org/apache/log4j/db/DataSourceConnectionSource.java
  
  Index: DataSourceConnectionSource.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/DataSourceConnectionSource.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DataSourceConnectionSource.java	19 Nov 2004 14:50:51 -0000	1.8
  +++ DataSourceConnectionSource.java	6 Jan 2005 17:03:10 -0000	1.9
  @@ -41,10 +41,6 @@
       //LogLog.debug("**********DataSourceConnectionSource.activateOptions called");
       if (dataSource == null) {
         getLogger().warn("WARNING: No data source specified");
  -      
  -      if (errorHandler != null) {
  -        errorHandler.error("WARNING: No data source specified");
  -      }
       } else {
         Connection connection = null;
         try {
  @@ -66,10 +62,7 @@
      */
     public Connection getConnection() throws SQLException {
       if (dataSource == null) {
  -      if (errorHandler != null) {
  -        errorHandler.error("WARNING: No data source specified");
  -      }
  -
  +      getLogger().error("WARNING: No data source specified");
         return null;
       }
   
  
  
  
  1.7       +4 -13     logging-log4j/src/java/org/apache/log4j/db/DriverManagerConnectionSource.java
  
  Index: DriverManagerConnectionSource.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/DriverManagerConnectionSource.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DriverManagerConnectionSource.java	24 Nov 2004 08:17:02 -0000	1.6
  +++ DriverManagerConnectionSource.java	6 Jan 2005 17:03:10 -0000	1.7
  @@ -16,8 +16,6 @@
   
   package org.apache.log4j.db;
   
  -import org.apache.log4j.spi.ErrorCode;
  -
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.SQLException;
  @@ -75,19 +73,12 @@
         if (driverClass != null) {
           Class.forName(driverClass);
           discoverConnnectionProperties();
  -      } else if (errorHandler != null) {
  -        errorHandler.error(
  -          "WARNING: No JDBC driver specified for log4j "
  -          + "DriverManagerConnectionSource.");
  -      }
  -    } catch (final ClassNotFoundException cnfe) {
  -      if (errorHandler != null) {
  -        errorHandler.error(
  -          "Could not load JDBC driver class: " + driverClass, cnfe,
  -          ErrorCode.GENERIC_FAILURE);
         } else {
  -        cnfe.printStackTrace();
  +        getLogger().error(
  +          "WARNING: No JDBC driver specified for log4j DriverManagerConnectionSource.");
         }
  +    } catch (final ClassNotFoundException cnfe) {
  +     getLogger().error("Could not load JDBC driver class: " + driverClass, cnfe);
       }
     }
   
  
  
  
  1.10      +0 -17     logging-log4j/src/java/org/apache/log4j/db/ConnectionSourceSkeleton.java
  
  Index: ConnectionSourceSkeleton.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/ConnectionSourceSkeleton.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ConnectionSourceSkeleton.java	4 Jan 2005 12:51:15 -0000	1.9
  +++ ConnectionSourceSkeleton.java	6 Jan 2005 17:03:10 -0000	1.10
  @@ -18,7 +18,6 @@
   
   import org.apache.log4j.db.dialect.Util;
   import org.apache.log4j.spi.ComponentBase;
  -import org.apache.log4j.spi.ErrorHandler;
   
   import java.sql.Connection;
   import java.sql.DatabaseMetaData;
  @@ -31,7 +30,6 @@
   public abstract class ConnectionSourceSkeleton extends ComponentBase implements ConnectionSource {
     protected String user = null;
     protected String password = null;
  -  protected ErrorHandler errorHandler = null;
   
     // initially we have an unkonw dialect
     protected int dialectCode = UNKNOWN_DIALECT;
  @@ -66,21 +64,6 @@
      */
     public boolean supportsGetGeneratedKeys() {
       return supportsGetGeneratedKeys;
  -  }
  -
  -  /**
  -   * Get teh errorHandler for this connection source
  -   */
  -  public ErrorHandler getErrorHandler() {
  -    return errorHandler;
  -  }
  -
  -  /**
  -   * Sets the error handler.
  -   * @param errorHandler  the error handler to set
  -   */
  -  public void setErrorHandler(ErrorHandler errorHandler) {
  -    this.errorHandler = errorHandler;
     }
   
     public int getSQLDialectCode() {
  
  
  
  1.6       +0 -1      logging-log4j/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
  
  Index: RelativeTimeDateFormat.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RelativeTimeDateFormat.java	26 Dec 2004 14:05:35 -0000	1.5
  +++ RelativeTimeDateFormat.java	6 Jan 2005 17:03:10 -0000	1.6
  @@ -28,7 +28,6 @@
      printing DateFormat in the package.
      
      @author Ceki Gülcü
  -   
      @since 0.7.5
   */
   public class RelativeTimeDateFormat extends DateFormat {
  
  
  
  1.9       +11 -0     logging-log4j/src/java/org/apache/log4j/helpers/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/helpers/Constants.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Constants.java	18 Nov 2004 22:48:02 -0000	1.8
  +++ Constants.java	6 Jan 2005 17:03:10 -0000	1.9
  @@ -45,4 +45,15 @@
     static final String TEMP_LIST_APPENDER_NAME = "TEMP_LIST_APPENDER";
     static final String TEMP_CONSOLE_APPENDER_NAME = "TEMP_CONSOLE_APPENDER";
     static final String CODES_HREF = "http://logging.apache.org/log4j/docs/codes.html";
  +  
  +  
  +  public static final String ABSOLUTE_FORMAT = "ABSOLUTE";
  +  public static final String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS";
  +
  +
  +  public static final String DATE_AND_TIME_FORMAT = "DATE";
  +  public static final String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
  +  
  +  public static final String ISO8601_FORMAT = "ISO8601";
  +  public static final String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
   }
  
  
  
  1.3       +6 -11     logging-log4j/src/java/org/apache/log4j/rolling/helper/Util.java
  
  Index: Util.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/rolling/helper/Util.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Util.java	2 Dec 2004 09:23:03 -0000	1.2
  +++ Util.java	6 Jan 2005 17:03:10 -0000	1.3
  @@ -16,9 +16,8 @@
   
   package org.apache.log4j.rolling.helper;
   
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Logger;
   import org.apache.log4j.rolling.RolloverFailure;
  +import org.apache.log4j.spi.ComponentBase;
   
   import java.io.File;
   import java.io.FileInputStream;
  @@ -29,11 +28,8 @@
    * Utility class to help solving problems encontered while renameing files.
    * @author Ceki Gulcu  
    */
  -public class Util {
  +public class Util extends ComponentBase {
   
  -  private static Logger getLogger() {
  -    return LogManager.getLogger(Util.class);
  -  }
     
     /**
      * A robust file renaming method which in case of failure falls back to
  @@ -45,7 +41,7 @@
      * @param to
      * @throws RolloverFailure
      */
  -  public static void rename(String from, String to) throws RolloverFailure {
  +  public void rename(String from, String to) throws RolloverFailure {
       File fromFile = new File(from);
       boolean success = false;
   
  @@ -56,9 +52,8 @@
         boolean result = fromFile.renameTo(toFile);
   
         if (!result) {
  -        Logger logger = getLogger();
  -        logger.warn("Failed to rename file [{}] to [{}].", fromFile, toFile);
  -        logger.warn("Attemting to rename by copying.");
  +        getLogger().warn("Failed to rename file [{}] to [{}].", fromFile, toFile);
  +        getLogger().warn("Attemting to rename by copying.");
           renameByCopying(from, to);
         }
       } else {
  @@ -66,7 +61,7 @@
       }
     }
   
  -  public static void renameByCopying(String from, String to)
  +  public void renameByCopying(String from, String to)
         throws RolloverFailure {
       try {
         FileInputStream fis = new FileInputStream(from);
  
  
  
  1.7       +0 -1      logging-log4j/src/java/org/apache/log4j/joran/util/JoranDocument.java
  
  Index: JoranDocument.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/util/JoranDocument.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JoranDocument.java	5 Jan 2005 17:18:00 -0000	1.6
  +++ JoranDocument.java	6 Jan 2005 17:03:11 -0000	1.7
  @@ -17,7 +17,6 @@
   package org.apache.log4j.joran.util;
   
   import org.apache.log4j.LogManager;
  -import org.apache.log4j.Logger;
   import org.apache.log4j.helpers.Constants;
   import org.apache.log4j.spi.ErrorItem;
   import org.apache.log4j.spi.LoggerRepository;
  
  
  
  1.2       +5 -3      logging-log4j/tests/src/java/org/apache/log4j/MinimumTest.java
  
  Index: MinimumTest.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/MinimumTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MinimumTest.java	21 Apr 2004 10:03:28 -0000	1.1
  +++ MinimumTest.java	6 Jan 2005 17:03:11 -0000	1.2
  @@ -20,7 +20,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.log4j.helpers.AbsoluteTimeDateFormat;
  +import org.apache.log4j.helpers.Constants;
   import org.apache.log4j.util.*;
   
   
  @@ -73,8 +73,10 @@
     }
   
     public void ttcc() throws Exception {
  -    Layout layout =
  -      new TTCCLayout(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT);
  +    TTCCLayout layout = new TTCCLayout();
  +    layout.setDateFormat(Constants.DATE_AND_TIME_FORMAT);
  +    layout.activateOptions();
  +    
       Appender appender = new FileAppender(layout, "output/ttcc", false);
       root.addAppender(appender);
       common();
  
  
  
  1.15      +0 -1      logging-log4j/tests/src/java/org/apache/log4j/pattern/CachedDateFormatTest.java
  
  Index: CachedDateFormatTest.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/pattern/CachedDateFormatTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- CachedDateFormatTest.java	31 Dec 2004 16:55:40 -0000	1.14
  +++ CachedDateFormatTest.java	6 Jan 2005 17:03:11 -0000	1.15
  @@ -20,7 +20,6 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -import org.apache.log4j.helpers.AbsoluteTimeDateFormat;
   import org.apache.log4j.pattern.CachedDateFormat;
   
   import java.text.DateFormat;
  
  
  
  1.24      +64 -44    logging-log4j/src/java/org/apache/log4j/TTCCLayout.java
  
  Index: TTCCLayout.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/TTCCLayout.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- TTCCLayout.java	21 Dec 2004 22:04:04 -0000	1.23
  +++ TTCCLayout.java	6 Jan 2005 17:03:11 -0000	1.24
  @@ -1,12 +1,12 @@
   /*
    * Copyright 1999,2004 The Apache Software Foundation.
  - * 
  + *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
  - * 
  + *
    *      http://www.apache.org/licenses/LICENSE-2.0
  - * 
  + *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  @@ -14,14 +14,19 @@
    * limitations under the License.
    */
   
  -
   // Contributors: Christopher Williams
   //               Mathias Bogaert
   package org.apache.log4j;
   
  -import org.apache.log4j.helpers.DateLayout;
  +import org.apache.log4j.helpers.Constants;
   import org.apache.log4j.spi.LoggingEvent;
   
  +import java.text.DateFormat;
  +import java.text.FieldPosition;
  +import java.text.SimpleDateFormat;
  +
  +import java.util.Date;
  +
   
   /**
    TTCC layout format consists of time, thread, category and nested
  @@ -60,45 +65,31 @@
     first two statements. The text after the '-' is the message of the
     statement.
   
  -  <p><b>WARNING</b> Do not use the same TTCCLayout instance from
  -  within different appenders. The TTCCLayout is not thread safe when
  -  used in his way. However, it is perfectly safe to use a TTCCLayout
  -  instance from just one appender.
  -
     <p>{@link PatternLayout} offers a much more flexible alternative.
   
     @author Ceki G&uuml;lc&uuml;
     @author <A HREF="mailto:heinz.richter@ecmwf.int">Heinz Richter</a>
  -  @deprecated Please use PatternLayout instead.
  +  @deprecated Please use {@link PatternLayout} instead.
   */
  -public class TTCCLayout extends DateLayout {
  -	
  +public class TTCCLayout extends Layout {
     // Internal representation of options
     private boolean threadPrinting = true;
     private boolean categoryPrefixing = true;
     private boolean contextPrinting = true;
     protected final StringBuffer buf = new StringBuffer(64);
  +  Date date = new Date();
  +  DateFormat formatter;
  +  protected FieldPosition pos = new FieldPosition(0);
   
     /**
  -     Instantiate a TTCCLayout object with {@link
  -     org.apache.log4j.helpers.RelativeTimeDateFormat} as the date
  -     formatter in the local time zone.
  -
  -     @since 0.7.5 */
  +   * Instantiate a TTCCLayout object with in the ISO8601 format as the date
  +   * formatter.
  +   * */
     public TTCCLayout() {
  -    this.setDateFormat(RELATIVE_TIME_DATE_FORMAT, null);
  +    this.setDateFormat(Constants.ISO8601_FORMAT);
     }
   
  -  /**
  -     Instantiate a TTCCLayout object using the local time zone. The
  -     DateFormat used will depend on the <code>dateFormatType</code>.
  -
  -     <p>This constructor just calls the {@link
  -     DateLayout#setDateFormat} method.
  -
  -     */
  -  public TTCCLayout(String dateFormatType) {
  -    this.setDateFormat(dateFormatType);
  +  public void activateOptions() {
     }
   
     /**
  @@ -147,6 +138,31 @@
       return contextPrinting;
     }
   
  +  public void setDateFormat(String dateFormatStr) {
  +    if (dateFormatStr == null) {
  +      this.formatter = null;
  +      return;
  +    }
  +    String dateFormatPattern = null;
  +
  +    if (dateFormatStr.equalsIgnoreCase("NULL")) {
  +      dateFormatPattern = null;
  +    } else if (dateFormatStr.equalsIgnoreCase(Constants.ABSOLUTE_FORMAT)) {
  +      dateFormatPattern = Constants.ABSOLUTE_TIME_PATTERN;
  +    } else if (
  +      dateFormatStr.equalsIgnoreCase(Constants.DATE_AND_TIME_FORMAT)) {
  +      dateFormatPattern = Constants.DATE_AND_TIME_PATTERN;
  +    } else if (dateFormatStr.equalsIgnoreCase(Constants.ISO8601_FORMAT)) {
  +      dateFormatPattern = Constants.ISO8601_PATTERN;
  +    } else {
  +      dateFormatPattern = dateFormatStr;
  +    }
  +
  +    if (dateFormatPattern != null) {
  +      formatter = new SimpleDateFormat(dateFormatPattern);
  +    }
  +  }
  +
     /**
      In addition to the level of the statement and message, the
      returned byte array includes time, thread, category and {@link NDC}
  @@ -155,37 +171,41 @@
      <p>Time, thread, category and diagnostic context are printed
      depending on options.
     */
  -  public void format(java.io.Writer output, LoggingEvent event) throws java.io.IOException {
  -  	
  -  	buf.setLength(0);
  -    dateFormat(buf, event);
  +  public void format(java.io.Writer output, LoggingEvent event)
  +    throws java.io.IOException {
  +    buf.setLength(0);
  +    if (formatter != null) {
  +      date.setTime(event.getTimeStamp());
  +      formatter.format(date, buf, this.pos);
  +      buf.append(' ');
  +    }
       output.write(buf.toString());
   
       if (this.threadPrinting) {
         output.write('[');
  -	  output.write(event.getThreadName());
  -	  output.write("] ");
  +      output.write(event.getThreadName());
  +      output.write("] ");
       }
   
  -	output.write(event.getLevel().toString());
  -	output.write(' ');
  +    output.write(event.getLevel().toString());
  +    output.write(' ');
   
       if (this.categoryPrefixing) {
  -		output.write(event.getLoggerName());
  -		output.write(' ');
  +      output.write(event.getLoggerName());
  +      output.write(' ');
       }
   
       if (this.contextPrinting) {
         String ndc = event.getNDC();
   
         if (ndc != null) {
  -		output.write(ndc);
  -		output.write(' ');
  +        output.write(ndc);
  +        output.write(' ');
         }
       }
   
  -	output.write("- ");
  -	output.write(event.getRenderedMessage());
  -	output.write(LINE_SEP);
  +    output.write("- ");
  +    output.write(event.getRenderedMessage());
  +    output.write(LINE_SEP);
     }
   }
  
  
  
  1.34      +13 -23    logging-log4j/src/java/org/apache/log4j/AppenderSkeleton.java
  
  Index: AppenderSkeleton.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/AppenderSkeleton.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AppenderSkeleton.java	3 Jan 2005 17:35:26 -0000	1.33
  +++ AppenderSkeleton.java	6 Jan 2005 17:03:11 -0000	1.34
  @@ -17,14 +17,10 @@
   package org.apache.log4j;
   
   import org.apache.log4j.Layout;
  -import org.apache.log4j.helpers.OnlyOnceErrorHandler;
   import org.apache.log4j.spi.ComponentBase;
  -import org.apache.log4j.spi.ErrorHandler;
   import org.apache.log4j.spi.Filter;
   import org.apache.log4j.spi.LoggingEvent;
   import org.apache.log4j.spi.OptionHandler;
  -import org.apache.ugli.ULogger;
  -
   
   /**
    * Abstract superclass of the other appenders in the package. This class
  @@ -37,12 +33,6 @@
    */
   public abstract class AppenderSkeleton extends ComponentBase implements Appender, OptionHandler {
     
  -  /*
  -   * An instance specific logger which must be accessed through the getLogger()
  -   * method. 
  -   */
  -  private ULogger logger;
  -  
     /**
      * The layout variable does not need to be set if the appender
      * implementation has its own layout.
  @@ -62,7 +52,7 @@
     /**
      * It is assumed and enforced that errorHandler is never null.
      */
  -  protected ErrorHandler errorHandler = new OnlyOnceErrorHandler();
  +  //protected ErrorHandler errorHandler = new OnlyOnceErrorHandler();
   
     /**
      * The first filter in the filter chain. Set to <code>null</code> initially.
  @@ -148,9 +138,9 @@
      *
      * @since 0.9.0
      */
  -  public ErrorHandler getErrorHandler() {
  -    return this.errorHandler;
  -  }
  +//  public ErrorHandler getErrorHandler() {
  +//    return this.errorHandler;
  +//  }
   
     /**
      * Returns the head Filter.
  @@ -257,15 +247,15 @@
      *
      * @since 0.9.0
      */
  -  public synchronized void setErrorHandler(ErrorHandler eh) {
  -    if (eh == null) {
  -      // We do not throw exception here since the cause is probably a
  -      // bad config file.
  -      getLogger().warn("You have tried to set a null error-handler.");
  -    } else {
  -      this.errorHandler = eh;
  -    }
  -  }
  +//  public synchronized void setErrorHandler(ErrorHandler eh) {
  +//    if (eh == null) {
  +//      // We do not throw exception here since the cause is probably a
  +//      // bad config file.
  +//      getLogger().warn("You have tried to set a null error-handler.");
  +//    } else {
  +//      this.errorHandler = eh;
  +//    }
  +//  }
   
     /**
      * Set the layout for this appender. Note that some appenders have their own
  
  
  
  1.29      +76 -64    logging-log4j/src/java/org/apache/log4j/WriterAppender.java
  
  Index: WriterAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/WriterAppender.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- WriterAppender.java	17 Nov 2004 21:25:23 -0000	1.28
  +++ WriterAppender.java	6 Jan 2005 17:03:11 -0000	1.29
  @@ -16,8 +16,6 @@
   
   package org.apache.log4j;
   
  -import org.apache.log4j.helpers.QuietWriter;
  -import org.apache.log4j.spi.ErrorHandler;
   import org.apache.log4j.spi.LoggingEvent;
   
   import java.io.IOException;
  @@ -36,6 +34,12 @@
      @author Ceki G&uuml;lc&uuml;
      @since 1.1 */
   public class WriterAppender extends AppenderSkeleton {
  +  
  +  /**
  +   * Set to true when the appender is in functioning order.
  +   */
  +  protected boolean inOrder = false;
  +  
     /**
        Immediate flush means that the underlying writer or output stream
        will be flushed at the end of each append operation. Immediate
  @@ -59,10 +63,9 @@
     protected String encoding;
   
     /**
  -     This is the {@link QuietWriter quietWriter} where we will write
  -     to.
  +   * This is the {@link Writer Writer} where we will write to.
     */
  -  protected QuietWriter qw;
  +  protected Writer writer;
   
     /**
        This default constructor does nothing.  */
  @@ -70,19 +73,26 @@
     }
   
     /**
  -     Instantiate a WriterAppender and set the output destination to a
  -     new {@link OutputStreamWriter} initialized with <code>os</code>
  -     as its {@link OutputStream}.  */
  +   * Instantiate a WriterAppender and set the output destination to a new 
  +   * {@link OutputStreamWriter} initialized with <code>os</code> as its 
  +   * {@link OutputStream}.  
  +   * 
  +   * @deprecated This constructor will be removed with no replacement in 
  +   * future log4j versions.
  +   * */
     public WriterAppender(Layout layout, OutputStream os) {
       this(layout, new OutputStreamWriter(os));
     }
   
     /**
  -     Instantiate a WriterAppender and set the output destination to
  -     <code>writer</code>.
  -
  -     <p>The <code>writer</code> must have been previously opened by
  -     the user.  */
  +   * Instantiate a WriterAppender and set the output destination to 
  +   * <code>writer</code>.
  +   * <p>
  +   * The <code>writer</code> must have been previously opened by the user. 
  +   * 
  +   * @deprecated This constructor will be removed with no replacement in 
  +   * future log4j versions 
  +   * */
     public WriterAppender(Layout layout, Writer writer) {
       this.layout = layout;
       this.setWriter(writer);
  @@ -114,9 +124,17 @@
     }
   
     /**
  -     Does nothing.
  +   * Does nothing.
     */
     public void activateOptions() {
  +    if (this.layout == null) {
  +      getLogger().error(
  +        "No layout set for the appender named [{}].", name);
  +    }
  +    
  +    if(this.writer != null) {
  +      inOrder = true;
  +    }
     }
   
     /**
  @@ -160,20 +178,13 @@
         return false;
       }
   
  -    if (this.qw == null) {
  -      errorHandler.error(
  -        "No output stream or file set for the appender named [" + name + "].");
  -
  -      return false;
  -    }
  -
  -    if (this.layout == null) {
  -      errorHandler.error(
  -        "No layout set for the appender named [" + name + "].");
  +    if (this.writer == null) {
  +      getLogger().error(
  +        "No output stream or file set for the appender named [{}].", name);
   
         return false;
       }
  -
  +    
       return true;
     }
   
  @@ -198,16 +209,14 @@
      * Close the underlying {@link java.io.Writer}.
      * */
     protected void closeWriter() {
  -    if (this.qw != null) {
  +    if (this.writer != null) {
         try {
           // before closing we have to output out layout's footer
           writeFooter();
  -        qw.close();
  -        this.qw = null;
  +        this.writer.close();
  +        this.writer = null;
         } catch (IOException e) {
  -        // There is do need to invoke an error handler at this late
  -        // stage.
  -        getLogger().error("Could not close " + qw, e);
  +        getLogger().error("Could not close writer for WriterAppener named "+name, e);
         }
       }
       
  @@ -249,21 +258,6 @@
     }
   
     /**
  -     Set the {@link ErrorHandler} for this WriterAppender and also the
  -     underlying {@link QuietWriter} if any. */
  -  public synchronized void setErrorHandler(ErrorHandler eh) {
  -    if (eh == null) {
  -      getLogger().warn("You have tried to set a null error-handler.");
  -    } else {
  -      this.errorHandler = eh;
  -
  -      if (this.qw != null) {
  -        this.qw.setErrorHandler(eh);
  -      }
  -    }
  -  }
  -
  -  /**
       <p>Sets the Writer where the log output will go. The
       specified Writer must be opened by the user and be
       writable.
  @@ -279,8 +273,7 @@
       // close any previously opened writer
       closeWriter();
       
  -    this.qw = new QuietWriter(writer, errorHandler);
  -
  +    this.writer = writer;
       //this.tp = new TracerPrintWriter(qw);
       writeHeader();
     }
  @@ -293,23 +286,32 @@
      * @since 0.9.0 
      * */
     protected void subAppend(LoggingEvent event) {
  -    this.qw.write(this.layout.format(event));
  +    if(!this.inOrder) {
  +      return;
  +    }
  +    
  +    try {
  +      this.writer.write(this.layout.format(event));
   
  -    if (layout.ignoresThrowable()) {
  -      String[] s = event.getThrowableStrRep();
  +      if (layout.ignoresThrowable()) {
  +        String[] s = event.getThrowableStrRep();
   
  -      if (s != null) {
  -        int len = s.length;
  +        if (s != null) {
  +          int len = s.length;
   
  -        for (int i = 0; i < len; i++) {
  -          this.qw.write(s[i]);
  -          this.qw.write(Layout.LINE_SEP);
  +          for (int i = 0; i < len; i++) {
  +            this.writer.write(s[i]);
  +            this.writer.write(Layout.LINE_SEP);
  +          }
           }
         }
  -    }
   
  -    if (this.immediateFlush) {
  -      this.qw.flush();
  +      if (this.immediateFlush) {
  +        this.writer.flush();
  +      }
  +    } catch(IOException ioe) {
  +      this.inOrder = false;
  +      getLogger().error("IO failure for appender named "+name, ioe);
       }
     }
   
  @@ -341,9 +343,14 @@
       if (layout != null) {
         String f = layout.getFooter();
   
  -      if ((f != null) && (this.qw != null)) {
  -        this.qw.write(f);
  -        this.qw.flush();
  +      if ((f != null) && (this.writer != null)) {
  +        try {
  +          this.writer.write(f);
  +          this.writer.flush();
  +        } catch(IOException ioe) {
  +          inOrder = false;
  +          getLogger().error("Failed to write footer for Appender named "+name, ioe);
  +        }
         }
       }
     }
  @@ -356,8 +363,13 @@
       if (layout != null) {
         String h = layout.getHeader();
   
  -      if ((h != null) && (this.qw != null)) {
  -        this.qw.write(h);
  +      if ((h != null) && (this.writer != null)) {
  +        try {
  +          this.writer.write(h);
  +        } catch(IOException ioe) {
  +          this.inOrder = false;
  +          getLogger().error("Failed to write header for WriterAppender named "+name, ioe);
  +        }
         }
       }
     }
  
  
  
  1.16      +2 -3      logging-log4j/src/java/org/apache/log4j/Appender.java
  
  Index: Appender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Appender.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Appender.java	3 Jan 2005 17:35:26 -0000	1.15
  +++ Appender.java	6 Jan 2005 17:03:11 -0000	1.16
  @@ -17,7 +17,6 @@
   package org.apache.log4j;
   
   import org.apache.log4j.spi.Component;
  -import org.apache.log4j.spi.ErrorHandler;
   import org.apache.log4j.spi.Filter;
   import org.apache.log4j.spi.LoggerRepository;
   import org.apache.log4j.spi.LoggingEvent;
  @@ -83,14 +82,14 @@
      *
      * @since 0.9.0
      */
  -  public void setErrorHandler(ErrorHandler errorHandler);
  +  //public void setErrorHandler(ErrorHandler errorHandler);
   
     /**
      * Returns the {@link ErrorHandler} for this appender.
      *
      * @since 1.1
      */
  -  public ErrorHandler getErrorHandler();
  +  //public ErrorHandler getErrorHandler();
   
     /**
      * Set the {@link Layout} for this appender.
  
  
  
  1.47      +8 -17     logging-log4j/src/java/org/apache/log4j/FileAppender.java
  
  Index: FileAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/FileAppender.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- FileAppender.java	24 Nov 2004 08:17:02 -0000	1.46
  +++ FileAppender.java	6 Jan 2005 17:03:11 -0000	1.47
  @@ -16,13 +16,9 @@
   
   package org.apache.log4j;
   
  -import org.apache.log4j.helpers.QuietWriter;
  -import org.apache.log4j.spi.ErrorCode;
  -
   import java.io.BufferedWriter;
   import java.io.FileOutputStream;
   import java.io.IOException;
  -import java.io.Writer;
   
   
   // Contibutors: Jens Uwe Pipka <jens.pipka@gmx.de>
  @@ -83,6 +79,7 @@
       int bufferSize) throws IOException {
       this.layout = layout;
       this.setFile(filename, append, bufferedIO, bufferSize);
  +    activateOptions();
     }
   
     /**
  @@ -98,6 +95,7 @@
       throws IOException {
       this.layout = layout;
       this.setFile(filename, append, false, bufferSize);
  +    activateOptions();
     }
   
     /**
  @@ -108,6 +106,7 @@
       <p>The file will be appended to.  */
     public FileAppender(Layout layout, String filename) throws IOException {
       this(layout, filename, true);
  +    activateOptions();
     }
   
     /**
  @@ -149,15 +148,15 @@
         try {
           setFile(fileName, fileAppend, bufferedIO, bufferSize);
         } catch (java.io.IOException e) {
  -        errorHandler.error(
  -          "setFile(" + fileName + "," + fileAppend + ") call failed.", e,
  -          ErrorCode.FILE_OPEN_FAILURE);
  +        getLogger().error(
  +          "setFile(" + fileName + "," + fileAppend + ") call failed.", e);
         }
       } else {
         //LogLog.error("File option not set for appender ["+name+"].");
         getLogger().warn("File option not set for appender [{}].", name);
         getLogger().warn("Are you using FileAppender instead of ConsoleAppender?");
       }
  +    super.activateOptions();
     }
   
     /**
  @@ -258,25 +257,17 @@
   
       closeWriter();
   
  -    Writer fw = createWriter(new FileOutputStream(filename, append));
  +    this.writer = createWriter(new FileOutputStream(filename, append));
   
       if (bufferedIO) {
  -      fw = new BufferedWriter(fw, bufferSize);
  +      this.writer = new BufferedWriter(this.writer, bufferSize);
       }
   
  -    this.setQWForFiles(fw);
       this.fileAppend = append;
       this.bufferedIO = bufferedIO;
       this.fileName = filename;
       this.bufferSize = bufferSize;
       writeHeader();
       getLogger().debug("setFile ended");
  -  }
  -
  -  /**
  -   * Sets the quiet writer being used.
  -   */
  -  protected void setQWForFiles(Writer writer) {
  -    this.qw = new QuietWriter(writer, errorHandler);
     }
   }
  
  
  
  1.18      +10 -12    logging-log4j/src/java/org/apache/log4j/pattern/DatePatternConverter.java
  
  Index: DatePatternConverter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/pattern/DatePatternConverter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DatePatternConverter.java	26 Dec 2004 14:09:29 -0000	1.17
  +++ DatePatternConverter.java	6 Jan 2005 17:03:11 -0000	1.18
  @@ -17,6 +17,7 @@
   package org.apache.log4j.pattern;
   
   import org.apache.log4j.Logger;
  +import org.apache.log4j.helpers.Constants;
   import org.apache.log4j.spi.LoggingEvent;
   import java.text.SimpleDateFormat;
   import java.util.TimeZone;
  @@ -35,10 +36,7 @@
     Logger logger = Logger.getLogger(DatePatternConverter.class);
     private CachedDateFormat df;
     private final StringBuffer buf = new StringBuffer(30); 
  -  public static final String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
  -  public static final String ABSOLUTE_PATTERN = "HH:mm:ss,SSS";
  -  public static final String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
  -  
  +
     //  public DatePatternConverter(FormattingInfo formattingInfo) {
     //    super(formattingInfo);
     //    this.buf = new StringBuffer(32);
  @@ -64,14 +62,14 @@
       }
       
       String pattern;
  -    if (patternOption == null || patternOption.equalsIgnoreCase("ISO8601")) {
  -      pattern = ISO8601_PATTERN;
  +    if (patternOption == null || patternOption.equalsIgnoreCase(Constants.ISO8601_FORMAT)) {
  +      pattern = Constants.ISO8601_PATTERN;
       } else if (
  -      patternOption.equalsIgnoreCase("ABSOLUTE")) {
  -      pattern = ABSOLUTE_PATTERN;
  +      patternOption.equalsIgnoreCase(Constants.ABSOLUTE_FORMAT)) {
  +      pattern = Constants.ABSOLUTE_TIME_PATTERN;
       } else if (
  -      patternOption.equalsIgnoreCase("DATE")) {
  -      pattern = DATE_AND_TIME_PATTERN;
  +      patternOption.equalsIgnoreCase(Constants.DATE_AND_TIME_FORMAT)) {
  +      pattern = Constants.DATE_AND_TIME_PATTERN;
       } else {
         pattern = patternOption;
       }
  @@ -85,9 +83,9 @@
         logger.warn(
           "Could not instantiate SimpleDateFormat with pattern " + patternOption, e);
         // default to the ISO8601 format
  -      simpleFormat = new SimpleDateFormat(ISO8601_PATTERN);
  +      simpleFormat = new SimpleDateFormat(Constants.ISO8601_PATTERN);
       }
  -  
  +   
        
       // if the option list contains a TZ option, then set it.
       if (optionList != null && optionList.size() > 1) {
  
  
  
  1.21      +0 -2      logging-log4j/src/java/org/apache/log4j/pattern/PatternParser.java
  
  Index: PatternParser.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/pattern/PatternParser.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- PatternParser.java	4 Jan 2005 19:42:12 -0000	1.20
  +++ PatternParser.java	6 Jan 2005 17:03:11 -0000	1.21
  @@ -16,11 +16,9 @@
   
   package org.apache.log4j.pattern;
   
  -import org.apache.log4j.LogManager;
   import org.apache.log4j.helpers.OptionConverter;
   import org.apache.log4j.spi.ComponentBase;
   import org.apache.log4j.spi.LoggerRepository;
  -import org.apache.ugli.ULogger;
   
   import java.util.HashMap;
   import java.util.Map;
  
  
  
  1.18      +3 -3      logging-log4j/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
  
  Index: TableColorizingRenderer.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TableColorizingRenderer.java	5 Dec 2004 10:17:36 -0000	1.17
  +++ TableColorizingRenderer.java	6 Jan 2005 17:03:11 -0000	1.18
  @@ -18,15 +18,15 @@
   
   import org.apache.log4j.chainsaw.color.Colorizer;
   import org.apache.log4j.chainsaw.icons.LevelIconFactory;
  -import org.apache.log4j.helpers.ISO8601DateFormat;
  +import org.apache.log4j.helpers.Constants;
   import org.apache.log4j.spi.LoggingEvent;
   
   import java.awt.Color;
   import java.awt.Component;
   
   import java.text.DateFormat;
  +import java.text.SimpleDateFormat;
   
  -import java.util.Calendar;
   import java.util.Date;
   import java.util.Map;
   
  @@ -49,7 +49,7 @@
    */
   public class TableColorizingRenderer extends DefaultTableCellRenderer {
     private static final DateFormat DATE_FORMATTER =
  -    new ISO8601DateFormat(Calendar.getInstance().getTimeZone());
  +    new SimpleDateFormat(Constants.ISO8601_PATTERN);
     private static final Map iconMap =
       LevelIconFactory.getInstance().getLevelToIconMap();
     private Colorizer colorizer;
  
  
  
  1.95      +1 -2      logging-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java
  
  Index: LogPanel.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/chainsaw/LogPanel.java,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- LogPanel.java	2 Jan 2005 09:51:40 -0000	1.94
  +++ LogPanel.java	6 Jan 2005 17:03:11 -0000	1.95
  @@ -126,7 +126,6 @@
   import org.apache.log4j.chainsaw.prefs.SaveSettingsEvent;
   import org.apache.log4j.chainsaw.prefs.SettingsManager;
   import org.apache.log4j.helpers.Constants;
  -import org.apache.log4j.helpers.ISO8601DateFormat;
   import org.apache.log4j.rule.ExpressionRule;
   import org.apache.log4j.rule.Rule;
   import org.apache.log4j.spi.LoggingEvent;
  @@ -496,7 +495,7 @@
               !model.isUseISO8601Format() && !model.isCustomDateFormat());
   
             if (model.isUseISO8601Format()) {
  -            renderer.setDateFormatter(new ISO8601DateFormat());
  +            renderer.setDateFormatter(new SimpleDateFormat(Constants.ISO8601_PATTERN));
             } else {
               renderer.setDateFormatter(
                 new SimpleDateFormat(model.getDateFormatPattern()));
  
  
  
  1.9       +10 -18    logging-log4j/src/java/org/apache/log4j/net/MulticastAppender.java
  
  Index: MulticastAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/MulticastAppender.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MulticastAppender.java	5 Jan 2005 17:27:57 -0000	1.8
  +++ MulticastAppender.java	6 Jan 2005 17:03:11 -0000	1.9
  @@ -96,6 +96,14 @@
         }
       }
   
  +    if(remoteHost != null) {
  +      address = getAddressByName(remoteHost);
  +    } else {
  +      String err = "The RemoteHost property is required for SocketAppender named "+ name;
  +      getLogger().error(err);
  +      throw new IllegalStateException(err);
  +    }
  +    
       connect();
     }
   
  @@ -139,7 +147,8 @@
         cleanUp();
         outSocket = new MulticastSocket();
         outSocket.setTimeToLive(timeToLive);
  -    } catch (IOException e) {e.printStackTrace();
  +    } catch (IOException e) {
  +      getLogger().error("Error in connect method of MulticastAppender named "+name, e);
       }
     }
   
  @@ -148,13 +157,6 @@
         return;
       }
   
  -    if (address == null) {
  -      errorHandler.error(
  -        "No remote host is set for MulticastAppender named \"" + this.name + "\".");
  -
  -      return;
  -    }
  -
       if (outSocket != null) {
         //if the values already exist, don't set (useful when forwarding from a simplesocketserver
         if (
  @@ -196,20 +198,10 @@
     }
   
     /**
  -     The MulticastAppender uses layouts (should be configured with XMLLayout to use MulticastReceiver.
  -      Hence, this method returns
  -     <code>true</code>.
  -  */
  -  public boolean requiresLayout() {
  -    return true;
  -  }
  -
  -  /**
        The <b>RemoteHost</b> option takes a string value which should be
        the host name or ipaddress to send the multicast packets.
      */
     public void setRemoteHost(String host) {
  -    address = getAddressByName(host);
       remoteHost = host;
     }
   
  
  
  
  1.26      +38 -53    logging-log4j/src/java/org/apache/log4j/net/SocketAppender.java
  
  Index: SocketAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/SocketAppender.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SocketAppender.java	5 Jan 2005 18:37:54 -0000	1.25
  +++ SocketAppender.java	6 Jan 2005 17:03:11 -0000	1.26
  @@ -158,8 +158,14 @@
           hostname = "unknown";
         }
       }
  -
  -    connect(address, port);
  +    if(remoteHost != null) {
  +      address = getAddressByName(remoteHost);
  +      connect(address, port);
  +    } else {
  +      String err = "The RemoteHost property is required for SocketAppender named "+ name;
  +      getLogger().error(err);
  +      throw new IllegalStateException(err);
  +    }
     }
   
     /**
  @@ -231,15 +237,7 @@
         return;
       }
   
  -    if (address == null) {
  -      errorHandler.error(
  -        "No remote host is set for SocketAppender named \"" + this.name
  -        + "\".");
  -
  -      return;
  -    }
  -
  -    if (oos != null) {
  +   if (oos != null) {
         try {
           if (locationInfo) {
             event.getLocationInformation();
  @@ -254,8 +252,6 @@
           }
   
           oos.writeObject(event);
  -
  -        //LogLog.debug("=========Flushing.");
           oos.flush();
   
           if (++counter >= RESET_FREQUENCY) {
  @@ -297,65 +293,56 @@
     }
   
     /**
  -   * The SocketAppender does not use a layout. Hence, this method
  -   * returns <code>false</code>.
  -   * */
  -  public boolean requiresLayout() {
  -    return false;
  -  }
  -
  -  /**
      * The <b>RemoteHost</b> option takes a string value which should be
  -   * the host name of the server where a {@link SocketNode} is
  -   * running.
  +   * the host name of the server where a {@link SocketNode} or a 
  +   * {@link SocketReceiver} is running.
      * */
     public void setRemoteHost(String host) {
  -    address = getAddressByName(host);
       remoteHost = host;
     }
   
     /**
  -         Returns value of the <b>RemoteHost</b> option.
  +   * Returns value of the <b>RemoteHost</b> option.
      */
     public String getRemoteHost() {
       return remoteHost;
     }
   
     /**
  -         The <b>Port</b> option takes a positive integer representing
  -         the port where the server is waiting for connections.
  +   * The <b>Port</b> option takes a positive integer representing the port 
  +   * where the server is waiting for connections.
      */
     public void setPort(int port) {
       this.port = port;
     }
   
     /**
  -         Returns value of the <b>Port</b> option.
  +   * Returns value of the <b>Port</b> option.
      */
     public int getPort() {
       return port;
     }
   
     /**
  -         The <b>LocationInfo</b> option takes a boolean value. If true,
  -         the information sent to the remote host will include location
  -         information. By default no location information is sent to the server.
  +   * The <b>LocationInfo</b> option takes a boolean value. If true, the 
  +   * information sent to the remote host will include location information. 
  +   * By default no location information is sent to the server.
      */
     public void setLocationInfo(boolean locationInfo) {
       this.locationInfo = locationInfo;
     }
   
     /**
  -         Returns value of the <b>LocationInfo</b> option.
  +   * Returns value of the <b>LocationInfo</b> option.
      */
     public boolean getLocationInfo() {
       return locationInfo;
     }
   
     /**
  -         * The <b>App</b> option takes a string value which should be the
  -         * name of the application getting logged
  -         * If property was already set (via system property), don't set here.
  +   * The <b>App</b> option takes a string value which should be the name of the 
  +   * application getting logged.
  +   * If property was already set (via system property), don't set here.
      */
     public void setApplication(String lapp) {
       this.application = lapp;
  @@ -369,36 +356,34 @@
     }
   
     /**
  -         The <b>ReconnectionDelay</b> option takes a positive integer
  -         representing the number of milliseconds to wait between each
  -         failed connection attempt to the server. The default value of
  -         this option is 30000 which corresponds to 30 seconds.
  -
  -         <p>Setting this option to zero turns off reconnection
  -         capability.
  +   * The <b>ReconnectionDelay</b> option takes a positive integer representing 
  +   * the number of milliseconds to wait between each failed connection attempt 
  +   * to the server. The default value of this option is 30000 which corresponds 
  +   * to 30 seconds. 
  +   * <p>
  +   * Setting this option to zero turns off reconnection capability.
      */
     public void setReconnectionDelay(int delay) {
       this.reconnectionDelay = delay;
     }
   
     /**
  -         Returns value of the <b>ReconnectionDelay</b> option.
  +   * Returns value of the <b>ReconnectionDelay</b> option.
      */
     public int getReconnectionDelay() {
       return reconnectionDelay;
     }
   
     /**
  -         The Connector will reconnect when the server becomes available
  -         again.  It does this by attempting to open a new connection every
  -         <code>reconnectionDelay</code> milliseconds.
  -
  -         <p>It stops trying whenever a connection is established. It will
  -         restart to try reconnect to the server when previpously open
  -         connection is droppped.
  -
  -         @author  Ceki G&uuml;lc&uuml;
  -         @since 0.8.4
  +   * The Connector will reconnect when the server becomes available again.  
  +   * It does this by attempting to open a new connection every 
  +   * <code>reconnectionDelay</code> milliseconds.
  +   * <p>
  +   * It stops trying whenever a connection is established. It will restart to 
  +   * try reconnect to the server when previpously open connection is droppped.
  +   * 
  +   * @author  Ceki G&uuml;lc&uuml;
  +   * @since 0.8.4
     */
     class Connector extends Thread {
       boolean interrupted = false;
  
  
  
  1.19      +29 -40    logging-log4j/src/java/org/apache/log4j/net/JMSAppender.java
  
  Index: JMSAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/JMSAppender.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JMSAppender.java	24 Nov 2004 08:32:02 -0000	1.18
  +++ JMSAppender.java	6 Jan 2005 17:03:11 -0000	1.19
  @@ -17,7 +17,6 @@
   package org.apache.log4j.net;
   
   import org.apache.log4j.AppenderSkeleton;
  -import org.apache.log4j.spi.ErrorCode;
   import org.apache.log4j.spi.LoggingEvent;
   
   import java.util.Properties;
  @@ -100,6 +99,9 @@
   
      @author Ceki G&uuml;lc&uuml; */
   public class JMSAppender extends AppenderSkeleton {
  +  
  +  static int SUCCESSIVE_FAILURE_LIMIT = 3;
  +  
     String securityPrincipalName;
     String securityCredentials;
     String initialContextFactoryName;
  @@ -114,6 +116,9 @@
     TopicSession topicSession;
     TopicPublisher topicPublisher;
   
  +  boolean inOrder = false;
  +  int successiveFailureCount = 0;
  +  
     public JMSAppender() {
     }
   
  @@ -196,37 +201,42 @@
           jndi = new InitialContext();
         }
   
  -      getLogger().debug("Looking up [" + tcfBindingName + "]");
  +      getLogger().debug("Looking up [{}]", tcfBindingName);
         topicConnectionFactory =
           (TopicConnectionFactory) lookup(jndi, tcfBindingName);
         getLogger().debug("About to create TopicConnection.");
         if (userName != null) {
  -        topicConnection =
  +        this.topicConnection =
             topicConnectionFactory.createTopicConnection(userName, password);
         } else {
  -        topicConnection = topicConnectionFactory.createTopicConnection();
  +        this.topicConnection = topicConnectionFactory.createTopicConnection();
         }
   
         getLogger().debug(
           "Creating TopicSession, non-transactional, "
           + "in AUTO_ACKNOWLEDGE mode.");
  -      topicSession =
  +      this.topicSession =
           topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
   
         getLogger().debug("Looking up topic name [" + topicBindingName + "].");
         Topic topic = (Topic) lookup(jndi, topicBindingName);
   
         getLogger().debug("Creating TopicPublisher.");
  -      topicPublisher = topicSession.createPublisher(topic);
  +      this.topicPublisher = topicSession.createPublisher(topic);
   
         getLogger().debug("Starting TopicConnection.");
         topicConnection.start();
   
         jndi.close();
       } catch (Exception e) {
  -      errorHandler.error(
  -        "Error while activating options for appender named [" + name + "].", e,
  -        ErrorCode.GENERIC_FAILURE);
  +      getLogger().error(
  +       "Error while activating options for appender named [" + name + "].", e);
  +    }
  +    
  +    if (this.topicConnection != null && this.topicSession != null && this.topicPublisher == null) {
  +      inOrder = true;
  +    } else {
  +      inOrder = false;
       }
     }
   
  @@ -239,25 +249,6 @@
       }
     }
   
  -  protected boolean checkEntryConditions() {
  -    String fail = null;
  -
  -    if (this.topicConnection == null) {
  -      fail = "No TopicConnection";
  -    } else if (this.topicSession == null) {
  -      fail = "No TopicSession";
  -    } else if (this.topicPublisher == null) {
  -      fail = "No TopicPublisher";
  -    }
  -
  -    if (fail != null) {
  -      errorHandler.error(fail + " for JMSAppender named [" + name + "].");
  -      return false;
  -    } else {
  -      return true;
  -    }
  -  }
  -
     /**
        Close this JMSAppender. Closing releases all resources used by the
        appender. A closed appender cannot be re-opened. */
  @@ -291,7 +282,7 @@
        This method called by {@link AppenderSkeleton#doAppend} method to
        do most of the real appending work.  */
     public void append(LoggingEvent event) {
  -    if (!checkEntryConditions()) {
  +    if (!inOrder) {
         return;
       }
   
  @@ -302,10 +293,16 @@
         }
         msg.setObject(event);
         topicPublisher.publish(msg);
  +      successiveFailureCount = 0;
       } catch (Exception e) {
  -      errorHandler.error(
  -        "Could not publish message in JMSAppender [" + name + "].", e,
  -        ErrorCode.GENERIC_FAILURE);
  +      successiveFailureCount++;
  +      if(successiveFailureCount > SUCCESSIVE_FAILURE_LIMIT) {
  +        inOrder = false;
  +      }
  +      getLogger().error(
  +        "Could not publish message in JMSAppender [" + name + "].", e);
  +   
  +      
       }
     }
   
  @@ -396,13 +393,5 @@
      * */
     public void setLocationInfo(boolean locationInfo) {
       this.locationInfo = locationInfo;
  -  }
  -
  -  /**
  -   * The JMSAppender sends serialized events and consequently does not
  -   * require a layout.
  -   * */
  -  public boolean requiresLayout() {
  -    return false;
     }
   }
  
  
  
  1.10      +10 -9     logging-log4j/src/java/org/apache/log4j/net/UDPAppender.java
  
  Index: UDPAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/net/UDPAppender.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- UDPAppender.java	20 Nov 2004 15:46:02 -0000	1.9
  +++ UDPAppender.java	6 Jan 2005 17:03:11 -0000	1.10
  @@ -23,7 +23,6 @@
   import java.net.UnknownHostException;
   
   import org.apache.log4j.AppenderSkeleton;
  -import org.apache.log4j.LogManager;
   import org.apache.log4j.helpers.*;
   import org.apache.log4j.spi.LoggingEvent;
   
  @@ -119,8 +118,14 @@
         }
       }
   
  -    //if not passed in, allow null app (app property won't be set)
  -    connect(address, port);
  +    if(remoteHost != null) {
  +      address = getAddressByName(remoteHost);
  +      connect(address, port);
  +    } else {
  +      String err = "The RemoteHost property is required for SocketAppender named "+ name;
  +      getLogger().error(err);
  +      throw new IllegalStateException(err);
  +    }
     }
   
     /**
  @@ -180,8 +185,6 @@
       }
   
       if (address == null) {
  -      errorHandler.error(
  -        "No remote host is set for UDPAppender named \"" + this.name + "\".");
         return;
       }
   
  @@ -219,12 +222,11 @@
       return !inError;
     }
     
  -  static InetAddress getAddressByName(String host) {
  +  InetAddress getAddressByName(String host) {
       try {
         return InetAddress.getByName(host);
       } catch (Exception e) {
  -      LogManager.getLogger(UDPAppender.class).error("Could not find address of [" + host + "].", e);
  -
  +      getLogger().error("Could not find address of [" + host + "].", e);
         return null;
       }
     }
  @@ -242,7 +244,6 @@
        the host name or ipaddress to send the UDP packets.
      */
     public void setRemoteHost(String host) {
  -    address = getAddressByName(host);
       remoteHost = host;
     }
   
  
  
  
  1.87      +2 -1      logging-log4j/tests/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/build.xml,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- build.xml	3 Jan 2005 11:05:45 -0000	1.86
  +++ build.xml	6 Jan 2005 17:03:12 -0000	1.87
  @@ -169,7 +169,8 @@
                                        CustomLogger, PatternLayout, 
                                        HierarchyThreshold, DefaultInit, 
                                        SocketServer,
  -                                     XMLLayout, AsyncAppender, ErrorHandler,
  +                                     XMLLayout, 
  +  	                                 AsyncAppender, 
                                        OptionSubstitutionTest,
     	                             LevelOptionConverterTest,
     				     BoundedFIFO, 
  
  
  
  1.70      +44 -44    logging-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
  
  Index: DOMConfigurator.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- DOMConfigurator.java	4 Jan 2005 19:42:12 -0000	1.69
  +++ DOMConfigurator.java	6 Jan 2005 17:03:12 -0000	1.70
  @@ -198,8 +198,8 @@
           // Parse appender parameters 
           if (currentElement.getTagName().equals(PARAM_TAG)) {
             setParameter(currentElement, propSetter);
  -        } else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG)) {
  -          parseErrorHandler(currentElement, appender);
  +        //} else if (currentElement.getTagName().equals(ERROR_HANDLER_TAG)) {
  +          //parseErrorHandler(currentElement, appender);
           } else if (currentElement.getTagName().equals(APPENDER_REF_TAG)) {
             String refName = subst(currentElement.getAttribute(REF_ATTR));
   
  @@ -332,48 +332,48 @@
     /**
        Used internally to parse an {@link ErrorHandler} element.
      */
  -  protected void parseErrorHandler(Element element, Appender appender) {
  -    ErrorHandler eh =
  -      (ErrorHandler) optionConverter.instantiateByClassName(
  -        subst(element.getAttribute(CLASS_ATTR)),
  -        org.apache.log4j.spi.ErrorHandler.class, null);
  -
  -    if (eh != null) {
  -      eh.setAppender(appender);
  -
  -      PropertySetter propSetter = new PropertySetter(eh);
  -      NodeList children = element.getChildNodes();
  -      final int length = children.getLength();
  -
  -      for (int loop = 0; loop < length; loop++) {
  -        Node currentNode = children.item(loop);
  -
  -        if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  -          Element currentElement = (Element) currentNode;
  -          String tagName = currentElement.getTagName();
  -
  -          if (tagName.equals(PARAM_TAG)) {
  -            setParameter(currentElement, propSetter);
  -          } else if (tagName.equals(APPENDER_REF_TAG)) {
  -            eh.setBackupAppender(findAppenderByReference(currentElement));
  -          } else if (tagName.equals(LOGGER_REF)) {
  -            String loggerName = currentElement.getAttribute(REF_ATTR);
  -            Logger logger = repository.getLogger(loggerName);
  -            eh.setLogger(logger);
  -          } else if (tagName.equals(ROOT_REF)) {
  -            Logger root = repository.getRootLogger();
  -            eh.setLogger(root);
  -          }
  -        }
  -      }
  -
  -      if (eh instanceof OptionHandler) {
  -        ((OptionHandler) eh).activateOptions();
  -      }
  -
  -      appender.setErrorHandler(eh);
  -    }
  -  }
  +//  protected void parseErrorHandler(Element element, Appender appender) {
  +//    ErrorHandler eh =
  +//      (ErrorHandler) optionConverter.instantiateByClassName(
  +//        subst(element.getAttribute(CLASS_ATTR)),
  +//        org.apache.log4j.spi.ErrorHandler.class, null);
  +//
  +//    if (eh != null) {
  +//      eh.setAppender(appender);
  +//
  +//      PropertySetter propSetter = new PropertySetter(eh);
  +//      NodeList children = element.getChildNodes();
  +//      final int length = children.getLength();
  +//
  +//      for (int loop = 0; loop < length; loop++) {
  +//        Node currentNode = children.item(loop);
  +//
  +//        if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
  +//          Element currentElement = (Element) currentNode;
  +//          String tagName = currentElement.getTagName();
  +//
  +//          if (tagName.equals(PARAM_TAG)) {
  +//            setParameter(currentElement, propSetter);
  +//          } else if (tagName.equals(APPENDER_REF_TAG)) {
  +//            eh.setBackupAppender(findAppenderByReference(currentElement));
  +//          } else if (tagName.equals(LOGGER_REF)) {
  +//            String loggerName = currentElement.getAttribute(REF_ATTR);
  +//            Logger logger = repository.getLogger(loggerName);
  +//            eh.setLogger(logger);
  +//          } else if (tagName.equals(ROOT_REF)) {
  +//            Logger root = repository.getRootLogger();
  +//            eh.setLogger(root);
  +//          }
  +//        }
  +//      }
  +//
  +//      if (eh instanceof OptionHandler) {
  +//        ((OptionHandler) eh).activateOptions();
  +//      }
  +//
  +//      appender.setErrorHandler(eh);
  +//    }
  +//  }
   
     /**
        Used internally to parse a filter element.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message