Hi all,

I've completed porting the remaining Receiver classes to the sandbox area. The below patch is what I have locally, and taking the generated jar and adding it as a dependency to Chainsaw makes everything compile nicely. I am not able to do any testing on this as yet, and figure a patch review is probably worthwhile at this stage.

These are all baseline copies from the log4j trunk. The DB* stuff needed more fiddling than the others. I had to comment out all internal logging statements in the DBAppender because AppenderSkeleton in 1.2 does not provide that. There is no concept of a sequence # either, so I munged that in the insert statement so that all the inserts have '0' as a sequence value. Given LoggingEvent in 1.2 doesn't have that anyway, I figure that's ok..

Curty, Scott and others, any chance you could review this please before I check it in?

(Note: I'll fix checkstyle issues later, I know there's tabs everywhere sorry)

Index: src/main/java/org/apache/log4j/db/DBAppender.java
===================================================================
--- src/main/java/org/apache/log4j/db/DBAppender.java   (revision 529843)
+++ src/main/java/org/apache/log4j/db/DBAppender.java   (working copy)
@@ -162,7 +162,7 @@
   }
   public void activateOptions() {
-    getLogger().debug("DBAppender.activateOptions called");
+/*    getLogger().debug("DBAppender.activateOptions called");*/
     if (connectionSource == null) {
       throw new IllegalStateException(
@@ -197,7 +197,7 @@
    *          The connectionSource to set.
    */
   public void setConnectionSource(ConnectionSource connectionSource) {
-    getLogger().debug("setConnectionSource called for DBAppender");
+/*    getLogger().debug("setConnectionSource called for DBAppender");*/
     this.connectionSource = connectionSource;
   }
@@ -209,7 +209,10 @@

           PreparedStatement insertStatement =
               connection.prepareStatement(insertSQL);
-          insertStatement.setLong(1, event.getSequenceNumber());
+
+/*          insertStatement.setLong(1, event.getSequenceNumber());*/
+                 insertStatement.setLong(0, 0);
+               
           insertStatement.setLong(2, event.getTimeStamp());
           insertStatement.setString(3, event.getRenderedMessage());
           insertStatement.setString(4, event.getLoggerName());
@@ -233,7 +236,7 @@

           int updateCount = insertStatement.executeUpdate();
           if (updateCount != 1) {
-              getLogger().warn("Failed to insert loggingEvent");
+/*              getLogger().warn("Failed to insert loggingEvent");*/
           }

           ResultSet rs = null;
@@ -250,7 +253,7 @@
                   }
                   throw ex;
               } catch(IllegalAccessException ex) {
- getLogger().warn("IllegalAccessException invoking PreparedStatement.getGeneratedKeys", ex); +/* getLogger().warn("IllegalAccessException invoking PreparedStatement.getGeneratedKeys", ex);*/
               }
           }

@@ -314,7 +317,7 @@
           String[] strRep = event.getThrowableStrRep();

           if (strRep != null) {
-              getLogger().debug("Logging an exception");
+/*              getLogger().debug("Logging an exception");*/

               PreparedStatement insertExceptionStatement =
                   connection.prepareStatement(insertExceptionSQL);
@@ -338,7 +341,7 @@

           connection.commit();
       } catch (Throwable sqle) {
-          getLogger().error("problem appending event", sqle);
+/*          getLogger().error("problem appending event", sqle);*/
       } finally {
           DBHelper.closeConnection(connection);
       }
Index: src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java
===================================================================
--- src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java (revision 529843) +++ src/main/java/org/apache/log4j/db/CustomSQLDBReceiver.java (working copy)
@@ -398,19 +398,24 @@
                     }
                     Level levelImpl = Level.toLevel(level);
-                    LoggingEvent event = new LoggingEvent(
- eventLogger.getName(), eventLogger, levelImpl,
-                            message, null);
- event.setLocationInformation(new LocationInfo (fileName,
-                            className, methodName, lineNumber));
+
+
+                                       LocationInfo locationInfo = new 
LocationInfo(fileName,
+                                   className, methodName, lineNumber);
+       
+                                       ThrowableInformation throwableInfo =  
new ThrowableInformation(
+                                           exception);
+       
                     properties.putAll(mdc);
-                    event.setTimeStamp(timeStamp);
- event.setThrowableInformation(new ThrowableInformation(
-                            exception));
-                    event.setProperties(properties);
-                    event.setThreadName(threadName);
-                    event.setNDC(ndc);
+                                   LoggingEvent event = new LoggingEvent(null,
+                                           eventLogger, timeStamp, levelImpl, 
message,
+                                           threadName,
+                                           throwableInfo,
+                                           ndc,
+                                           locationInfo,
+                                           properties);
+
                     doPost(event);
                 }
                 //log when rows are retrieved
Index: src/main/java/org/apache/log4j/db/DBReceiverJob.java
===================================================================
--- src/main/java/org/apache/log4j/db/DBReceiverJob.java (revision 529843)
+++ src/main/java/org/apache/log4j/db/DBReceiverJob.java        (working copy)
@@ -32,6 +32,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Hashtable;
import java.util.Vector;
/**
@@ -75,38 +76,62 @@
       //rs.beforeFirst();
       while (rs.next()) {
-        LoggingEvent event = new LoggingEvent();
+           Logger logger = null;
+           long timeStamp = 0L;
+           String level = null;
+           String threadName = null;
+           Object message = null;
+           String ndc = null;
+           String className = null;
+           String methodName = null;
+           String fileName = null;
+           String lineNumber = null;
+           Hashtable properties = new Hashtable();
-        event.setSequenceNumber(rs.getLong(1));
-        event.setTimeStamp(rs.getLong(2));
-        event.setRenderedMessage(rs.getString(3));
-        event.setLoggerName(rs.getString(4));
-        String levelStr = rs.getString(5);
-        // TODO CG The conversion of levelStr should be more general
-        Level level = Level.toLevel(levelStr);
-        event.setLevel(level);
-        event.setNDC(rs.getString(6));
-        event.setThreadName(rs.getString(7));
+        //event.setSequenceNumber(rs.getLong(1));
+        timeStamp = rs.getLong(2);
+        message = rs.getString(3);
+               logger = Logger.getLogger(rs.getString(4));
+        level = rs.getString(5);
+               Level levelImpl = Level.toLevel(level.trim());
+
+        ndc = rs.getString(6);
+        threadName = rs.getString(7);
         short mask = rs.getShort(8);
-        String fileName = rs.getString(9);
-        String className = rs.getString(10);
-        String methodName = rs.getString(11);
-        String lineNumber = rs.getString(12).trim();
+        fileName = rs.getString(9);
+        className = rs.getString(10);
+        methodName = rs.getString(11);
+        lineNumber = rs.getString(12).trim();
+               LocationInfo locationInfo = null;
         if (fileName.equals(LocationInfo.NA)) {
-          event.setLocationInformation(LocationInfo.NA_LOCATION_INFO);
+          locationInfo = LocationInfo.NA_LOCATION_INFO;
         } else {
- event.setLocationInformation(new LocationInfo(fileName, className,
-              methodName, lineNumber));
+          locationInfo = new LocationInfo(fileName, className,
+              methodName, lineNumber);
         }
         long id = rs.getLong(13);
         //LogLog.info("Received event with id=" + id);
         lastId = id;
+               ThrowableInformation throwableInfo = null;
+        if ((mask & DBHelper.EXCEPTION_EXISTS) != 0) {
+          throwableInfo = getException(connection, id);
+        }
+
+           LoggingEvent event = new LoggingEvent(null,
+                   logger, timeStamp, levelImpl, message,
+                   threadName,
+                   throwableInfo,
+                   ndc,
+                   locationInfo,
+                   properties);
+
+
         // Scott asked for this info to be
         event.setProperty(Constants.LOG4J_ID_KEY, Long.toString(id));
@@ -114,9 +139,8 @@
           getProperties(connection, id, event);
         }
-        if ((mask & DBHelper.EXCEPTION_EXISTS) != 0) {
-          getException(connection, id, event);
-        }
+
+
         if (!parentDBReceiver.isPaused()) {
           parentDBReceiver.doPost(event);
@@ -177,7 +201,7 @@
    * @param event
    * @throws SQLException
    */
-  void getException(Connection connection, long id, LoggingEvent event)
+  ThrowableInformation getException(Connection connection, long id)
       throws SQLException {
     PreparedStatement statement = null;
@@ -200,7 +224,7 @@
         strRep[i] = (String) v.get(i);
       }
       // we've filled strRep, we now attach it to the event
-      event.setThrowableInformation(new ThrowableInformation(strRep));
+      return new ThrowableInformation(strRep);
     } finally {
       if (statement != null) {
         statement.close();
Index: pom.xml
===================================================================
--- pom.xml     (revision 529792)
+++ pom.xml     (working copy)
@@ -117,6 +117,11 @@
       <artifactId>oro</artifactId>
       <version>2.0.8</version>
     </dependency>
+    <dependency>
+      <groupId>javax.jms</groupId>
+      <artifactId>jms</artifactId>
+      <version>1.1</version>
+    </dependency>
   </dependencies>
   <reporting>
     <plugins>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to