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/db ConnectionSourceSkeleton.java
Date Thu, 18 Nov 2004 22:48:03 GMT
ceki        2004/11/18 14:48:03

  Modified:    src/java/org/apache/log4j/helpers Constants.java
               tests/input/xml customLogger3.xml customLogger2.xml
                        customLogger1.xml DOMTestCase1.xml
               src/java/org/apache/joran Interpreter.java
               tests/src/java/org/apache/log4j PatternLayoutTest.java
               src/java/org/apache/log4j/db/dialect Util.java
               src/java/org/apache/log4j RollingFileAppender.java
                        AppenderSkeleton.java
               src/java/org/apache/log4j/joran JoranConfigurator.java
               src/java/org/apache/log4j/db ConnectionSourceSkeleton.java
  Log:
  - LogLog -> Logger changes
  - Better documentation
  - Minor stuff
  
  Revision  Changes    Path
  1.8       +1 -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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Constants.java	16 Nov 2004 20:29:44 -0000	1.7
  +++ Constants.java	18 Nov 2004 22:48:02 -0000	1.8
  @@ -44,4 +44,5 @@
     
     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";
   }
  
  
  
  1.4       +6 -0      logging-log4j/tests/input/xml/customLogger3.xml
  
  Index: customLogger3.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger3.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- customLogger3.xml	26 May 2004 17:56:17 -0000	1.3
  +++ customLogger3.xml	18 Nov 2004 22:48:02 -0000	1.4
  @@ -13,6 +13,12 @@
       </layout>
     </appender>
     
  +  <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
  +  <logger name="org.apache.log4j.joran"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.xml.Log4jEntityResolver"><level value="ERROR"
/></logger>
  +
     <root>
       <level value ="TRACE" class="org.apache.log4j.xml.XLevel"/>
       <appender-ref ref="TEMP" />
  
  
  
  1.4       +6 -0      logging-log4j/tests/input/xml/customLogger2.xml
  
  Index: customLogger2.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger2.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- customLogger2.xml	26 May 2004 17:56:17 -0000	1.3
  +++ customLogger2.xml	18 Nov 2004 22:48:02 -0000	1.4
  @@ -21,6 +21,12 @@
       <filter class="org.apache.log4j.varia.DenyAllFilter"/>
     </appender>
     
  +  <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
  +  <logger name="org.apache.log4j.joran"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.xml.Log4jEntityResolver"><level value="ERROR"
/></logger>
  +
     <root>
       <level value ="TRACE" class="org.apache.log4j.xml.XLevel"/>
       <appender-ref ref="TEMP" />
  
  
  
  1.4       +7 -1      logging-log4j/tests/input/xml/customLogger1.xml
  
  Index: customLogger1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger1.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- customLogger1.xml	26 May 2004 17:56:17 -0000	1.3
  +++ customLogger1.xml	18 Nov 2004 22:48:02 -0000	1.4
  @@ -12,7 +12,13 @@
   	value="%-5p %c{2} - %m%n"/>
       </layout>     
     </appender>
  -  
  +
  +   <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
  +  <logger name="org.apache.log4j.joran"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
  +  <logger name="org.apache.log4j.xml.Log4jEntityResolver"><level value="ERROR"
/></logger>
  +
     <root>
       <level value ="TRACE" class="org.apache.log4j.xml.XLevel"/>
       <appender-ref ref="TEMP" />
  
  
  
  1.5       +1 -1      logging-log4j/tests/input/xml/DOMTestCase1.xml
  
  Index: DOMTestCase1.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/input/xml/DOMTestCase1.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMTestCase1.xml	18 Nov 2004 20:00:28 -0000	1.4
  +++ DOMTestCase1.xml	18 Nov 2004 22:48:02 -0000	1.5
  @@ -20,7 +20,7 @@
       </layout>		
     </appender>
   
  -  <!-- Turn off internal DEBUG messages -->
  +  <!-- Prevent internal log4j DEBUG messages from polluting the output. -->
     <logger name="org.apache.log4j.joran"><level value="INFO" /></logger>
     <logger name="org.apache.log4j.config"><level value="INFO" /></logger>
     <logger name="org.apache.log4j.FileAppender"><level value="INFO" /></logger>
  
  
  
  1.17      +3 -0      logging-log4j/src/java/org/apache/joran/Interpreter.java
  
  Index: Interpreter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/Interpreter.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Interpreter.java	17 Nov 2004 21:25:25 -0000	1.16
  +++ Interpreter.java	18 Nov 2004 22:48:03 -0000	1.17
  @@ -72,6 +72,9 @@
     Pattern pattern;
     Locator locator;
   
  +  // The entity resolver is only needed in order to be compatible with
  +  // XML files written for DOMConfigurator containing the following DOCTYPE
  +  // <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
     private EntityResolver entityResolver;
     
     /**
  
  
  
  1.5       +15 -15    logging-log4j/tests/src/java/org/apache/log4j/PatternLayoutTest.java
  
  Index: PatternLayoutTest.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/PatternLayoutTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PatternLayoutTest.java	27 Feb 2004 16:47:36 -0000	1.4
  +++ PatternLayoutTest.java	18 Nov 2004 22:48:03 -0000	1.5
  @@ -81,7 +81,7 @@
     }
   
     public void test1() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout1.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout1.properties");
       common();
       Transformer.transform(
         TEMP, FILTERED,
  @@ -93,7 +93,7 @@
     }
   
     public void test2() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout2.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout2.properties");
       common();
   
       ControlFilter cf1 =
  @@ -109,7 +109,7 @@
     }
   
     public void test3() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout3.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout3.properties");
       common();
   
       ControlFilter cf1 =
  @@ -127,7 +127,7 @@
     // Output format:
     // 06 avr. 2002 18:30:58,937 [main] DEBUG atternLayoutTest - Message 0  
     public void test4() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout4.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout4.properties");
       common();
   
       ControlFilter cf1 =
  @@ -143,7 +143,7 @@
     }
   
     public void test5() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout5.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout5.properties");
       common();
   
       ControlFilter cf1 =
  @@ -160,7 +160,7 @@
   
     // 18:54:19,201 [main] DEBUG atternLayoutTest - Message 0
     public void test6() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout6.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout6.properties");
       common();
   
       ControlFilter cf1 =
  @@ -176,7 +176,7 @@
     }
   
     public void test7() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout7.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout7.properties");
       common();
   
       ControlFilter cf1 =
  @@ -192,7 +192,7 @@
     }
   
     public void test8() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout8.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout8.properties");
       common();
   
       ControlFilter cf1 =
  @@ -208,7 +208,7 @@
     }
   
     public void test9() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout9.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout9.properties");
       common();
   
       ControlFilter cf1 =
  @@ -224,7 +224,7 @@
     }
   
     public void test10() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout10.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout10.properties");
       common();
   
       ControlFilter cf1 =
  @@ -240,7 +240,7 @@
     }
   
     public void test11() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout11.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout11.properties");
       common();
   
       ControlFilter cf1 =
  @@ -256,7 +256,7 @@
     }
   
     public void test12() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout12.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout12.properties");
       common();
   
       ControlFilter cf1 =
  @@ -272,7 +272,7 @@
     }
   
     public void test13() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout13.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout13.properties");
       common();
   
       ControlFilter cf1 =
  @@ -288,7 +288,7 @@
     }
   
     public void test14() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout14.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout14.properties");
       common();
   
       ControlFilter cf1 =
  @@ -304,7 +304,7 @@
     }
   
     public void testMDC1() throws Exception {
  -    PropertyConfigurator.configure("input/patternLayout.mdc.1.properties");
  +    PropertyConfigurator.configure("input/pattern/patternLayout.mdc.1.properties");
       MDC.put("key1", "va11");
       MDC.put("key2", "va12");
       logger.debug("Hello World");
  
  
  
  1.8       +8 -6      logging-log4j/src/java/org/apache/log4j/db/dialect/Util.java
  
  Index: Util.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/db/dialect/Util.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Util.java	6 Jun 2004 12:17:32 -0000	1.7
  +++ Util.java	18 Nov 2004 22:48:03 -0000	1.8
  @@ -16,8 +16,9 @@
   
   package org.apache.log4j.db.dialect;
   
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.db.ConnectionSource;
  -import org.apache.log4j.helpers.LogLog;
   
   import java.sql.DatabaseMetaData;
   import java.sql.SQLException;
  @@ -36,13 +37,15 @@
     private static final String MSSQL_PART = "microsoft";
     private static final String HSQL_PART = "hsql";
     
  +  static Logger getLogger() {
  +    return LogManager.getLogger(Util.class);
  +  }
     public static int discoverSQLDialect(DatabaseMetaData meta) {
       int dialectCode = 0;
   
       try {
   
         String dbName = meta.getDatabaseProductName().toLowerCase();
  -      LogLog.debug("==db name is [" + dbName +"]");
   
         if (dbName.indexOf(POSTGRES_PART) != -1) {
           return ConnectionSource.POSTGRES_DIALECT;
  @@ -51,7 +54,6 @@
         } else if (dbName.indexOf(ORACLE_PART) != -1) {
           return ConnectionSource.ORACLE_DIALECT;
         } else if (dbName.indexOf(MSSQL_PART) != -1) {
  -        LogLog.info("Selecting MsSQL dialect");
           return ConnectionSource.MSSQL_DIALECT;
         } else if (dbName.indexOf(HSQL_PART) != -1) {
           return ConnectionSource.HSQL_DIALECT;
  @@ -102,8 +104,8 @@
       try {
         return meta.supportsGetGeneratedKeys();
       } catch(Throwable e) {
  -      LogLog.warn("The following warning is only informative.");
  -      LogLog.warn("Could not call supportsGetGeneratedKeys method. This may be recoverable");
  +      getLogger().warn("The following warning is only informative.");
  +      getLogger().warn("Could not call supportsGetGeneratedKeys method. This may be recoverable");
         return false;
       }
     }
  @@ -117,7 +119,7 @@
       try {
         return meta.supportsBatchUpdates();
       } catch(Throwable e) {
  -      LogLog.warn("Missing DatabaseMetaData.supportsBatchUpdates method.");
  +      getLogger().warn("Missing DatabaseMetaData.supportsBatchUpdates method.");
         return false;
       }
     }
  
  
  
  1.22      +1 -1      logging-log4j/src/java/org/apache/log4j/RollingFileAppender.java
  
  Index: RollingFileAppender.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/RollingFileAppender.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- RollingFileAppender.java	17 Nov 2004 21:25:23 -0000	1.21
  +++ RollingFileAppender.java	18 Nov 2004 22:48:03 -0000	1.22
  @@ -31,7 +31,7 @@
   
      @author Heinz Richter
      @author Ceki G&uuml;lc&uuml;
  -
  +   @deprecated Replaced by {@link org.apache.rolling.RollingFileAppender}
   */
   public class RollingFileAppender extends FileAppender {
     /**
  
  
  
  1.28      +2 -2      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AppenderSkeleton.java	17 Nov 2004 17:38:05 -0000	1.27
  +++ AppenderSkeleton.java	18 Nov 2004 22:48:03 -0000	1.28
  @@ -36,7 +36,7 @@
   public abstract class AppenderSkeleton implements Appender, OptionHandler {
     
     /*
  -   * An inststance specific logger. 
  +   * An insttance specific logger. 
      */
     private Logger logger;
     
  @@ -294,7 +294,7 @@
     }
     
     /**
  -   * Return an instance specifi logger to be used by the Appender itself.
  +   * Return an instance specific logger to be used by the Appender itself.
      * This logger is not intended to be used by Mrs. Piggy, our proverbial user,
      * hence the protected keyword.
      * 
  
  
  
  1.18      +4 -0      logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java
  
  Index: JoranConfigurator.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JoranConfigurator.java	17 Nov 2004 21:25:25 -0000	1.17
  +++ JoranConfigurator.java	18 Nov 2004 22:48:03 -0000	1.18
  @@ -184,6 +184,10 @@
       rs.addRule(new Pattern("*/param"), new ParamAction());
   
       joranInterpreter = new Interpreter(rs);
  +    
  +    // We need to bother with an entity resolver in order to be compatible
  +    // with config files written for DOMConfigurator containing the following: 
  +    // <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
       joranInterpreter.setEntityResolver(new Log4jEntityResolver());
       
       // The following line adds the capability to parse nested components
  
  
  
  1.8       +23 -8     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionSourceSkeleton.java	4 Jun 2004 10:16:21 -0000	1.7
  +++ ConnectionSourceSkeleton.java	18 Nov 2004 22:48:03 -0000	1.8
  @@ -16,8 +16,9 @@
   
   package org.apache.log4j.db;
   
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.db.dialect.Util;
  -import org.apache.log4j.helpers.LogLog;
   import org.apache.log4j.spi.ErrorHandler;
   
   import java.sql.Connection;
  @@ -37,7 +38,23 @@
     protected int dialectCode = UNKNOWN_DIALECT;
     protected boolean supportsGetGeneratedKeys = false;
     protected boolean supportsBatchUpdates = false;
  -  
  +
  +  // Per instance logger
  +  private Logger logger;
  +
  +  /**
  +   * Return an instance specific logger to be used by the ConnectionSource
  +   * itself. This logger is not intended to be used by Mrs. Piggy, hence the
  +   * protected keyword.
  +   *
  +   * @return instance specific logger
  +   */
  +  protected Logger getLogger() {
  +    if (logger == null) {
  +      logger = LogManager.getLogger(this.getClass().getName());
  +    }
  +    return logger;
  +  }
   
     /**
      * Learn relevant information about this connection source.
  @@ -46,8 +63,8 @@
     public void discoverConnnectionProperties() {
       try {
         Connection connection = getConnection();
  -      if(connection == null) {
  -        LogLog.warn("Could not get a conneciton");
  +      if (connection == null) {
  +        logger.warn("Could not get a conneciton");
           return;
         }
         DatabaseMetaData meta = connection.getMetaData();
  @@ -55,7 +72,7 @@
         supportsBatchUpdates = Util.supportsBatchUpdates(meta);
         dialectCode = Util.discoverSQLDialect(meta);
       } catch (SQLException se) {
  -      LogLog.warn("Could not discover the dialect to use.", se);
  +      getLogger().warn("Could not discover the dialect to use.", se);
       }
     }
   
  @@ -92,7 +109,6 @@
       return password;
     }
   
  -
     /**
      * Sets the password.
      * @param password The password to set
  @@ -115,12 +131,11 @@
     public void setUser(String username) {
       this.user = username;
     }
  -  
  +
     /**
      * Does this connection support batch updates?
      */
     public boolean supportsBatchUpdates() {
       return supportsBatchUpdates;
     }
  -
   }
  
  
  

---------------------------------------------------------------------
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