Index: src/edu/ucsb/nceas/metacat/ElementNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ElementNode.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/ElementNode.java	(revision 2663)
@@ -35,6 +35,8 @@
 import java.util.TreeSet;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
+
 /**
  * A Class that represents an XML element and its contents,
  * and can build itself from a database connection
@@ -41,6 +43,8 @@
  */
 public class ElementNode extends BasicNode {
 
+  private static Logger logMetacat = Logger.getLogger(ElementNode.class);
+
   /** 
    * Construct a new ElementNode instance, and recursively create its children
    *
@@ -57,10 +61,10 @@
     while (it.hasNext()) {
       NodeRecord currentNode = (NodeRecord)it.next();
       if (currentNode.nodeid == nodeid) {
-        util.debugMessage("Got Node ID: " + currentNode.nodeid +
+        logMetacat.info("Got Node ID: " + currentNode.nodeid +
                           " (" + currentNode.parentnodeid +
                           ", " + currentNode.nodeindex + 
-                          ", " + currentNode.nodetype + ")", 50);
+                          ", " + currentNode.nodetype + ")");
         // Process the current node
         setNodeType(currentNode.nodetype);
         setNodeID(currentNode.nodeid);
@@ -69,13 +73,13 @@
       } else {
         // Process the children nodes
         if (currentNode.parentnodeid == getNodeID()) {
-          util.debugMessage("  Processing child: " + currentNode.nodeid +
+        	logMetacat.info("  Processing child: " + currentNode.nodeid +
                           " (" + currentNode.parentnodeid +
                           ", " + currentNode.nodeindex + 
-                          ", " + currentNode.nodetype + ")", 50);
+                          ", " + currentNode.nodetype + ")");
 
           if ((currentNode.nodetype).equals("ELEMENT")) {
-            util.debugMessage("Creating child node: " + currentNode.nodeid, 50);
+        	logMetacat.info("Creating child node: " + currentNode.nodeid);
             ElementNode child = new ElementNode(nodeRecordList,
                                                 currentNode.nodeid);
             addChildNode(child);
@@ -100,10 +104,10 @@
           }
 
         } else {
-          util.debugMessage("  Discarding child: " + currentNode.nodeid +
+        	logMetacat.info("  Discarding child: " + currentNode.nodeid +
                           " (" + currentNode.parentnodeid +
                           ", " + currentNode.nodeindex +
-                          ", " + currentNode.nodetype + ")", 50);
+                          ", " + currentNode.nodetype + ")");
         }
       }
     }
Index: src/edu/ucsb/nceas/metacat/QuerySpecification.java
===================================================================
--- src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/QuerySpecification.java	(revision 2663)
@@ -40,6 +40,7 @@
 
 import edu.ucsb.nceas.dbadapter.AbstractDatabase;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -115,6 +116,8 @@
 
     private StringBuffer textBuffer = new StringBuffer();
 
+    private static Logger logMetacat = Logger.getLogger(QuerySpecification.class);
+
     /**
      * construct an instance of the QuerySpecification class
      *
@@ -235,7 +238,7 @@
             ownerQuery = ownerQuery + "lower(user_owner) ='" + userName + "'";
         }
 
-        MetaCatUtil.debugMessage("OwnerQuery: " + ownerQuery, 30);
+        logMetacat.info("OwnerQuery: " + ownerQuery);
         return ownerQuery;
     }
 
@@ -249,7 +252,7 @@
         String allowString = constructAllowString();
         allowQuery = "SELECT docid from xml_access WHERE( " + allowString;
         allowQuery = allowQuery + ") AND subtreeid IS NULL";
-        MetaCatUtil.debugMessage("allow query is: " + allowQuery, 30);
+        logMetacat.info("allow query is: " + allowQuery);
         return allowQuery;
 
     }
@@ -281,7 +284,7 @@
                 }//if
             }//for
         }//if
-        MetaCatUtil.debugMessage("allow string is: " + allowQuery, 40);
+        logMetacat.info("allow string is: " + allowQuery);
         return allowQuery;
     }
 
@@ -296,7 +299,7 @@
         String denyString = constructDenyString();
         denyQuery = "SELECT docid from xml_access WHERE( " + denyString;
         denyQuery = denyQuery + ") AND subtreeid IS NULL ";
-        MetaCatUtil.debugMessage("denyquery is: " + denyQuery, 30);
+        logMetacat.info("denyquery is: " + denyQuery);
         return denyQuery;
 
     }
@@ -349,7 +352,7 @@
         accessQuery = " AND (docid IN(" + onwer + ")";
         accessQuery = accessQuery + " OR (docid IN (" + allow + ")"
                 + " AND docid NOT IN (" + deny + ")))";
-        MetaCatUtil.debugMessage("accessquery is: " + accessQuery, 30);
+        logMetacat.warn("accessquery is: " + accessQuery);
         return accessQuery;
     }
 
@@ -632,8 +635,8 @@
         // make sure if return fields has an attribute or not
         if (inputString.indexOf(ATTRIBUTESYMBOL) == -1) {
             // no attribute value will be returned
-            MetaCatUtil.debugMessage("QuerySpecification.handleReturnField(): " , 35);
-            MetaCatUtil.debugMessage("  there are no attributes in the XPATH statement" , 35);
+            logMetacat.info("QuerySpecification.handleReturnField(): " );
+            logMetacat.info("  there are no attributes in the XPATH statement" );
             returnFieldList.add(inputString);
             containsExtendedSQL = true;
         } else {
@@ -641,8 +644,8 @@
           if ( inputString.startsWith(ATTRIBUTESYMBOL) ) {
 
             // case where the return field is solely an attribute
-            MetaCatUtil.debugMessage("QuerySpecification.handleReturnField(): " , 35);
-            MetaCatUtil.debugMessage("  there are *only* attributes in the XPATH statement" , 35);
+            logMetacat.info("QuerySpecification.handleReturnField(): " );
+            logMetacat.info("  there are *only* attributes in the XPATH statement" );
             String returnPath = newPathExpressionWithOutAttribute(inputString);
             String attributeName = getAttributeName(inputString);
             Vector pathInfo = new Vector();
@@ -662,9 +665,9 @@
             // has a attribute return field
             // divied the return filed into two parts, one is path and the
             // other is attribue name
-            MetaCatUtil.debugMessage("QuerySpecification.handleReturnField: " , 35);
-            MetaCatUtil.debugMessage("  there are both attributes and elements" , 35);
-            MetaCatUtil.debugMessage("  in the XPATH statement" , 35);
+            logMetacat.info("QuerySpecification.handleReturnField: " );
+            logMetacat.info("  there are both attributes and elements" );
+            logMetacat.info("  in the XPATH statement" );
             String returnPath = newPathExpressionWithOutAttribute(inputString);
             String attributeName = getAttributeName(inputString);
             Vector pathInfo = new Vector();
@@ -768,10 +771,10 @@
         // if there is only one percentage search item, this query is a
         // percentage
         // search query
-        MetaCatUtil.debugMessage("percentage number: "
-                + query.getPercentageSymbolCount(), 35);
+        logMetacat.info("percentage number: "
+                + query.getPercentageSymbolCount());
         if (query.getPercentageSymbolCount() == 1) {
-            MetaCatUtil.debugMessage("it is a percentage search", 30);
+            logMetacat.info("It is a percentage search");
             percentageSearch = true;
         }
 
@@ -815,8 +818,8 @@
         sql.append(")");
         sql.append(")");
         sql.append(")");
-        MetaCatUtil.debugMessage("accessControlSQLForReturnField: "
-                + sql.toString(), 30);
+        logMetacat.info("accessControlSQLForReturnField: "
+                + sql.toString());
         return sql.toString();
     }
 
@@ -883,7 +886,7 @@
     public String printExtendedSQL(String doclist,
             Hashtable unaccessableNodePair)
     {
-        MetaCatUtil.debugMessage("querySpecification.printExtendedSQL called\n", 35);
+        logMetacat.info("querySpecification.printExtendedSQL called\n");
         StringBuffer self = new StringBuffer();
 
         boolean usePathIndex = true;
@@ -1080,7 +1083,7 @@
                 self.append(" AND xml_nodes.rootnodeid = xml_documents.rootnodeid");
             }
 
-            MetaCatUtil.debugMessage("Attribute query: " + self.toString(), 30);
+            logMetacat.warn("Attribute query: " + self.toString());
 
             return self.toString();
         }
@@ -1117,8 +1120,8 @@
                     self.append(returnPath);
                     self.append("' AND ");
                 }else {
-                  MetaCatUtil.debugMessage("QuerySpecification.printAttributeQuery: "
-                   + "returnPath is: " + returnPath, 30);
+                  logMetacat.info("QuerySpecification.printAttributeQuery: "
+                   + "returnPath is: " + returnPath);
                 }
                 self.append("xml_nodes.nodename like '");
                 self.append(attributeName);
@@ -1130,8 +1133,8 @@
                     self.append(returnPath);
                     self.append("' AND ");
                 }else {
-                  MetaCatUtil.debugMessage("QuerySpecification.printAttributeQuery: "
-                   + "returnPath is null: " + returnPath, 30);
+                  logMetacat.info("QuerySpecification.printAttributeQuery: "
+                   + "returnPath is null: " + returnPath);
                 }
                 self.append("xml_nodes.nodename like '");
                 self.append(attributeName);
@@ -1141,7 +1144,7 @@
         self.append(") AND xml_nodes.docid in (");
         self.append(doclist);
         self.append(") AND xml_nodes.nodetype = 'ATTRIBUTE'");
-        MetaCatUtil.debugMessage("Attribute query: " + self.toString(), 30);
+        logMetacat.warn("Attribute query: " + self.toString());
 
         return self.toString();
     }
@@ -1187,8 +1190,8 @@
         if (index != 0) {
             newExpression = pathExpression.substring(0, index - 1);
         }
-        MetaCatUtil.debugMessage("The path expression without attributes: "
-                + newExpression, 30);
+        logMetacat.info("The path expression without attributes: "
+                + newExpression);
         return newExpression;
     }
 
@@ -1202,8 +1205,8 @@
         if (index != 1) {
             attributeName = path.substring(index + 1, size);
         }
-        MetaCatUtil.debugMessage("The attirbute name from path: "
-                + attributeName, 30);
+        logMetacat.info("The attirbute name from path: "
+                + attributeName);
         return attributeName;
     }
 
Index: src/edu/ucsb/nceas/metacat/MetacatReplication.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatReplication.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/MetacatReplication.java	(revision 2663)
@@ -38,6 +38,7 @@
 import javax.servlet.*;
 import javax.servlet.http.*;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.*;
 
 public class MetacatReplication extends HttpServlet implements Runnable
@@ -55,7 +56,8 @@
   private static final String TIMEREPLICATIONINTERVAl = "timedreplicationinterval";
   private static final String FIRSTTIME  = "firsttimedreplication";
   private static final int    TIMEINTERVALLIMIT = 7200000;
-  
+  private static Logger logMetacat = Logger.getLogger(MetacatReplication.class);
+
   /**
    * Initialize the servlet by creating appropriate database connections
    */
@@ -70,14 +72,14 @@
     try
     {
        timedReplicationIsOn = (new Boolean(util.getOption(TIMEREPLICATION ).trim())).booleanValue();
-       MetaCatUtil.debugMessage("The timed replication on is"+timedReplicationIsOn, 30);
+       logMetacat.info("The timed replication on is"+timedReplicationIsOn);
        timeInterval = (new Long(util.getOption(TIMEREPLICATIONINTERVAl).trim())).longValue();
-       MetaCatUtil.debugMessage("The timed replication time Inerval is "+ timeInterval, 20);
+       logMetacat.warn("The timed replication time Inerval is "+ timeInterval);
        String firstTimeStr = util.getOption(FIRSTTIME);
-       MetaCatUtil.debugMessage("first replication time form property is "+firstTimeStr, 20);
+       logMetacat.warn("first replication time form property is "+firstTimeStr);
        firstTime = ReplicationHandler.combinateCurrentDateAndGivenTime(firstTimeStr);
-       MetaCatUtil.debugMessage("After combine current time, the real first time is "
-                                +firstTime.toString()+" minisec", 20);
+       logMetacat.warn("After combine current time, the real first time is "
+                                +firstTime.toString()+" minisec");
        // set up time replication if it is on
        if (timedReplicationIsOn)
        {
@@ -90,9 +92,9 @@
     {
         // the timed replication in Metacat.properties file has problem
         // so timed replication is setting to false;
-        MetaCatUtil.debugMessage("Couldn't set up timed replication "+
+        logMetacat.error("Couldn't set up timed replication "+
                      " in Metacat replication servlet init because " +
-                 e.getMessage(), 20);
+                 e.getMessage());
         MetacatReplication.replErrorLog("Couldn't set up timed replication "+
                 " in Metacat replication servlet init because " +
                 e.getMessage());
@@ -176,15 +178,15 @@
           if (params.containsKey("sessionid")) 
           {
              sess_id = ((String[]) params.get("sessionid"))[0];
-             MetaCatUtil.debugMessage("in has sessionid "+ sess_id, 40);
+             logMetacat.info("in has sessionid "+ sess_id);
              if (sessionHash.containsKey(sess_id)) 
              {
-                  MetaCatUtil.debugMessage("find the id " + sess_id + " in hash table", 40);
+                  logMetacat.info("find the id " + sess_id + " in hash table");
                   sess = (HttpSession) sessionHash.get(sess_id);
              }
            } 
            username = (String) sess.getAttribute("username");
-           MetaCatUtil.debugMessage("The user name from session is: "+ username, 20);
+           logMetacat.warn("The user name from session is: "+ username);
            groupnames = (String[]) sess.getAttribute("groupnames");
            if (!MetaCatUtil.isAdministrator(username, groupnames)) 
            {
@@ -194,8 +196,8 @@
                        "\" is not authorized for this action.");
                out.print("</error>");
                out.close();
-               MetaCatUtil.debugMessage("The user \"" + username +
-                       "\" is not authorized for this action: " +action, 30);
+               logMetacat.warn("The user \"" + username +
+                       "\" is not authorized for this action: " +action);
                replErrorLog("The user \"" + username +
                        "\" is not authorized for this action: " +action);
                return;
@@ -249,7 +251,7 @@
       } else {
         timeInterval = TIMEINTERVALLIMIT ;
       }
-      MetaCatUtil.debugMessage("New rate is: " + timeInterval + " mini seconds.", 30);
+      logMetacat.info("New rate is: " + timeInterval + " mini seconds.");
       if ( params.containsKey("firsttime"))
       {
          firstTimeStr = ((String[])params.get("firsttime"))[0];
@@ -256,21 +258,21 @@
          try
          {
            firstTime = ReplicationHandler.combinateCurrentDateAndGivenTime(firstTimeStr);
-           MetaCatUtil.debugMessage("The first time setting is "+firstTime.toString(), 30);
+           logMetacat.info("The first time setting is "+firstTime.toString());
          }
          catch (Exception e)
          {
             throw new ServletException(e.getMessage());
          }
-         MetaCatUtil.debugMessage("After combine current time, the real first time is "
-                                  +firstTime.toString()+" minisec", 20);
+         logMetacat.warn("After combine current time, the real first time is "
+                                  +firstTime.toString()+" minisec");
       }
       else
       {
           MetacatReplication.replErrorLog("You should specify the first time " +
                                           "to start a time replication");
-          MetaCatUtil.debugMessage("You should specify the first time " +
-                                  "to start a time replication", 30);
+          logMetacat.warn("You should specify the first time " +
+                                  "to start a time replication");
           return;
       }
       
@@ -497,9 +499,9 @@
       }//try
       catch (SQLException ee)
       {
-        MetaCatUtil.debugMessage("Error in " +
+        logMetacat.error("Error in " +
                 "MetacatReplication.handleServerControlRequest to close pstmt "
-                 + ee.getMessage(), 30);
+                 + ee.getMessage());
       }//catch
       finally
       {
@@ -592,9 +594,9 @@
         //override = true; //we are now overriding the default action
       }
       MetacatReplication.replLog("force replication request from " + server);
-      MetaCatUtil.debugMessage("Force replication request from: "+ server, 34);
-      MetaCatUtil.debugMessage("Force replication docid: "+docid, 34);
-      MetaCatUtil.debugMessage("Force replication action: "+dbaction, 34);
+      logMetacat.info("Force replication request from: "+ server);
+      logMetacat.info("Force replication docid: "+docid);
+      logMetacat.info("Force replication action: "+dbaction);
       // sending back read request to remote server
       URL u = new URL("https://" + server + "?server="
                 +util.getLocalReplicationServerName()
@@ -620,29 +622,29 @@
       String homeServer=(String)docinfoHash.get("home_server");
       String createdDate = (String)docinfoHash.get("date_created");
       String updatedDate = (String)docinfoHash.get("date_updated");
-      MetaCatUtil.debugMessage("homeServer: "+homeServer, 34);
+      logMetacat.info("homeServer: "+homeServer);
       // Get Document type
       String docType = (String)docinfoHash.get("doctype");
-      MetaCatUtil.debugMessage("docType: "+docType, 34);
+      logMetacat.info("docType: "+docType);
       String parserBase = null;
       // this for eml2 and we need user eml2 parser
       if (docType != null &&
           (docType.trim()).equals(DocumentImpl.EML2_0_0NAMESPACE))
       {
-         MetaCatUtil.debugMessage("This is an eml200 document!", 30);
+         logMetacat.warn("This is an eml200 document!");
          parserBase = DocumentImpl.EML200;
       }
       else if (docType != null && (docType.trim()).equals(DocumentImpl.EML2_0_1NAMESPACE))
       {
-         MetaCatUtil.debugMessage("This is an eml2.0.1 document!", 30);
+         logMetacat.warn("This is an eml2.0.1 document!");
          parserBase = DocumentImpl.EML200;
       }
       else if (docType != null && (docType.trim()).equals(DocumentImpl.EML2_1_0NAMESPACE))
       {
-         MetaCatUtil.debugMessage("This is an eml2.1.0 document!", 30);
+         logMetacat.warn("This is an eml2.1.0 document!");
          parserBase = DocumentImpl.EML210;
       }
-      MetaCatUtil.debugMessage("The parserBase is: "+parserBase, 30);
+      logMetacat.warn("The parserBase is: "+parserBase);
 
       // Get DBConnection from pool
       dbConn=DBConnectionPool.
@@ -663,8 +665,8 @@
                                       " failed to added to DB with " +
                                       "action " + dbaction + " because "+
                                        e.getMessage());
-      MetaCatUtil.debugMessage("ERROR in MetacatReplication.handleForceReplicate" +
-                         "Request(): " + e.getMessage(), 30);
+      logMetacat.error("ERROR in MetacatReplication.handleForceReplicate" +
+                         "Request(): " + e.getMessage());
 
     }//catch
     finally
@@ -687,11 +689,11 @@
   {
     MetacatReplication.replLog("force replication delete request from " + server);
     MetacatReplication.replLog("force replication delete docid " + docid);
-    MetaCatUtil.debugMessage("Force replication delete request from: "+ server, 34);
-    MetaCatUtil.debugMessage("Force replication delete docid: "+docid, 34);
+    logMetacat.info("Force replication delete request from: "+ server);
+    logMetacat.info("Force replication delete docid: "+docid);
     DocumentImpl.delete(docid, null, null, server);
     MetacatReplication.replLog("document " + docid + " was successfully deleted ");
-    MetaCatUtil.debugMessage("document " + docid + " was successfully deleted ", 34);
+    logMetacat.info("document " + docid + " was successfully deleted ");
   }
   catch(Exception e)
   {
@@ -698,8 +700,8 @@
     MetacatReplication.replErrorLog("document " + docid +
                                     " failed to delete because "+
                                      e.getMessage());
-    MetaCatUtil.debugMessage("ERROR in MetacatReplication.handleForceDeleteReplicate" +
-                       "Request(): " + e.getMessage(), 30);
+    logMetacat.error("ERROR in MetacatReplication.handleForceDeleteReplicate" +
+                       "Request(): " + e.getMessage());
 
   }//catch
 
@@ -726,8 +728,7 @@
     // Make sure there is a docid and server
     if (docid==null || server==null || server.equals(""))
     {
-      MetaCatUtil.debugMessage("Didn't specify docid or server for replication"
-                              , 20);
+      logMetacat.error("Didn't specify docid or server for replication");
       return;
     }
 
@@ -751,9 +752,9 @@
       }
 
       MetacatReplication.replLog("force replication request from " + server);
-      MetaCatUtil.debugMessage("Force replication request from: "+ server, 34);
-      MetaCatUtil.debugMessage("Force replication docid: "+docid, 34);
-      MetaCatUtil.debugMessage("Force replication action: "+dbaction, 34);
+      logMetacat.info("Force replication request from: "+ server);
+      logMetacat.info("Force replication docid: "+docid);
+      logMetacat.info("Force replication action: "+dbaction);
       // get the document info from server
       URL docinfourl = new URL("https://" + server +
                                "?server="+util.getLocalReplicationServerName()
@@ -777,7 +778,7 @@
       String createdDate = (String)docinfoHash.get("date_created");
       
       String updatedDate = (String)docinfoHash.get("date_updated");
-      MetaCatUtil.debugMessage("docHomeServer of datafile: "+docHomeServer, 34);
+      logMetacat.info("docHomeServer of datafile: "+docHomeServer);
 
 
 
@@ -818,9 +819,9 @@
                                       " failed to added to DB with " +
                                       "action " + dbaction + " because "+
                                        e.getMessage());
-      MetaCatUtil.debugMessage
+      logMetacat.error
               ("ERROR in MetacatReplication.handleForceDataFileReplicate" +
-                         "Request(): " + e.getMessage(), 30);
+                         "Request(): " + e.getMessage());
     }
   }
   /**
@@ -942,7 +943,7 @@
     //check if the doicd is null
     if (docId==null)
     {
-      util.debugMessage("Didn't specify docid for replication", 20);
+      logMetacat.error("Didn't specify docid for replication");
       return;
     }
 
@@ -960,7 +961,7 @@
       {
         //response.setContentType("text/xml");
         //outPut.println("<error>Couldn't pass the trust test</error>");
-        MetaCatUtil.debugMessage("Couldn't pass the trust test", 20);
+        logMetacat.error("Couldn't pass the trust test");
         return;
       }
     }//try
@@ -1080,8 +1081,8 @@
     }
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("error getting document from MetacatReplication."
-                          +"handlGetDocumentRequest " + e.getMessage(), 30);
+      logMetacat.error("error getting document from MetacatReplication."
+                          +"handlGetDocumentRequest " + e.getMessage());
       //e.printStackTrace(System.out);
       response.setContentType("text/xml");
       out.println("<error>"+e.getMessage()+"</error>");
@@ -1191,7 +1192,7 @@
         docsql.append(serverLocation);
         revisionSql.append(serverLocation);
       }
-      MetaCatUtil.debugMessage("Doc sql: "+docsql.toString(), 30);
+      logMetacat.info("Doc sql: "+docsql.toString());
 
       // Get any deleted documents
       delsql.append("select distinct docid from ");
@@ -1203,7 +1204,7 @@
       {
         delsql.append("and server_location = 1");
       }
-      MetaCatUtil.debugMessage("Deleted sql: "+delsql.toString(), 30);
+      logMetacat.info("Deleted sql: "+delsql.toString());
 
 
 
@@ -1322,7 +1323,7 @@
       doclist.append(prepareRevisionDoc(dbConn,revisionSql.toString(),replicateData));
         
       doclist.append("</updates></replication>");
-      MetaCatUtil.debugMessage("doclist: " + doclist.toString(), 40);
+      logMetacat.info("doclist: " + doclist.toString());
       pstmt.close();
       //conn.close();
       response.setContentType("text/xml");
@@ -1331,8 +1332,8 @@
     }
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("error in MetacatReplication." +
-                         "handleupdaterequest: " + e.getMessage(), 30);
+      logMetacat.error("error in MetacatReplication." +
+                         "handleupdaterequest: " + e.getMessage());
       //e.printStackTrace(System.out);
       response.setContentType("text/xml");
       out.println("<error>"+e.getMessage()+"</error>");
@@ -1345,8 +1346,8 @@
       }//try
       catch (SQLException ee)
       {
-        MetaCatUtil.debugMessage("Error in MetacatReplication." +
-                "handleUpdaterequest to close pstmt: "+ee.getMessage(), 30);
+        logMetacat.error("Error in MetacatReplication." +
+                "handleUpdaterequest to close pstmt: "+ee.getMessage());
       }//catch
       finally
       {
@@ -1363,7 +1364,7 @@
   private String prepareRevisionDoc(DBConnection dbConn, String revSql, 
                             boolean replicateData) throws Exception
   {
-      MetaCatUtil.debugMessage("The revision document sql is "+ revSql, 20);
+      logMetacat.warn("The revision document sql is "+ revSql);
       StringBuffer revDocList = new StringBuffer();
       PreparedStatement pstmt = dbConn.prepareStatement(revSql);
       //usage count should increas 1
@@ -1470,8 +1471,8 @@
     catch(Exception e)
     {
 
-      MetaCatUtil.debugMessage("error in MetacatReplication.handleGetCatalogRequest:"+
-                          e.getMessage(), 30);
+      logMetacat.error("error in MetacatReplication.handleGetCatalogRequest:"+
+                          e.getMessage());
       e.printStackTrace(System.out);
       if(printFlag)
       {
@@ -1486,9 +1487,8 @@
       }//try
       catch (SQLException ee)
       {
-        MetaCatUtil.
-           debugMessage("Error in MetacatReplication.handleGetCatalogRequest: "
-           +ee.getMessage(), 30);
+        logMetacat.error("Error in MetacatReplication.handleGetCatalogRequest: "
+           +ee.getMessage());
       }//catch
       finally
       {
@@ -1524,13 +1524,13 @@
   {
     try
     {
-      MetaCatUtil.debugMessage("thread started for docid: " +
-                               (String)fileLocks.elementAt(0), 45);
+      logMetacat.info("thread started for docid: " +
+                               (String)fileLocks.elementAt(0));
 
       Thread.sleep(30000); //the lock will expire in 30 seconds
-      MetaCatUtil.debugMessage("thread for docid: " +
+      logMetacat.info("thread for docid: " +
                              (String)fileLocks.elementAt(fileLocks.size() - 1) +
-                              " exiting.", 45);
+                              " exiting.");
 
       fileLocks.remove(fileLocks.size() - 1);
       //fileLocks is treated as a FIFO queue.  If there are more than one lock
@@ -1538,8 +1538,8 @@
     }
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("error in file lock thread from " +
-                                "MetacatReplication.run: " + e.getMessage(), 30);
+      logMetacat.error("error in file lock thread from " +
+                                "MetacatReplication.run: " + e.getMessage());
     }
   }
 
@@ -1589,8 +1589,8 @@
       }//try
       catch (SQLException ee)
       {
-        MetaCatUtil.debugMessage("Error in MetacactReplication.getserver: "+
-                                    ee.getMessage(), 30);
+        logMetacat.error("Error in MetacactReplication.getserver: "+
+                                    ee.getMessage());
       }//catch
       finally
       {
@@ -1646,8 +1646,8 @@
        }//try
        catch(Exception ee)
        {
-         MetaCatUtil.debugMessage("Error in MetacatReplicatio.getServerCode: "
-                                  +ee.getMessage(), 30);
+         logMetacat.error("Error in MetacatReplicatio.getServerCode: "
+                                  +ee.getMessage());
 
        }//catch
        finally
@@ -1737,8 +1737,8 @@
       }
       catch (Exception ee)
       {
-        MetaCatUtil.debugMessage("Eror irn rplicationHandler.getHomeServer() "+
-                          "to close pstmt: "+ee.getMessage(), 30);
+        logMetacat.error("Eror irn rplicationHandler.getHomeServer() "+
+                          "to close pstmt: "+ee.getMessage());
       }
       finally
       {
@@ -1809,8 +1809,8 @@
       }
       catch(Exception ee)
       {
-        MetaCatUtil.debugMessage("Erorr in Replication.getServerLocation "+
-                     "to close pstmt"+ee.getMessage(), 30);
+        logMetacat.error("Erorr in Replication.getServerLocation "+
+                     "to close pstmt"+ee.getMessage());
       }
       finally
       {
@@ -1832,9 +1832,9 @@
   {
     char istreamChar;
     int istreamInt;
-    MetaCatUtil.debugMessage("Before open the stream"+u.toString(), 50);
+    logMetacat.info("Before open the stream"+u.toString());
     InputStream input = u.openStream();
-    MetaCatUtil.debugMessage("Afetr open the stream"+u.toString(), 50);
+    logMetacat.info("Afetr open the stream"+u.toString());
     InputStreamReader istream = new InputStreamReader(input);
     StringBuffer serverResponse = new StringBuffer();
     while((istreamInt = istream.read()) != -1)
@@ -1953,8 +1953,8 @@
       }//try
       catch(Exception ee)
       {
-        MetaCatUtil.debugMessage("Error in MetacatReplication.replToServer: "
-                                  +ee.getMessage(), 30);
+        logMetacat.error("Error in MetacatReplication.replToServer: "
+                                  +ee.getMessage());
       }//catch
       finally
       {
Index: src/edu/ucsb/nceas/metacat/DBSAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBSAXHandler.java	(revision 2663)
@@ -41,6 +41,7 @@
 import edu.ucsb.nceas.morpho.datapackage.Triple;
 import edu.ucsb.nceas.morpho.datapackage.TripleCollection;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
@@ -136,6 +137,8 @@
 
     public static final String ECOGRID = "ecogrid://";
 
+    private Logger logMetacat = Logger.getLogger(DBSAXHandler.class);
+
     /**
      * Construct an instance of the handler class
      *
@@ -218,7 +221,7 @@
     /** SAX Handler that receives notification of beginning of the document */
     public void startDocument() throws SAXException
     {
-        MetaCatUtil.debugMessage("start Document", 50);
+        logMetacat.info("start Document");
 
         // Create the document node representation as root
         rootNode = new DBSAXNode(connection, this.docid);
@@ -230,7 +233,7 @@
     /** SAX Handler that receives notification of end of the document */
     public void endDocument() throws SAXException
     {
-        MetaCatUtil.debugMessage("end Document", 50);
+        logMetacat.info("end Document");
         // Starting new thread for writing XML Index.
         // It calls the run method of the thread.
 
@@ -247,9 +250,9 @@
                         connection, tripleList);
                 }
             } catch (Exception e) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Failed to write triples into relation table"
-                                + e.getMessage(), 30);
+                                + e.getMessage());
                 throw new SAXException(
                         "Failed to write triples into relation table "
                                 + e.getMessage());
@@ -261,7 +264,7 @@
     public void startPrefixMapping(String prefix, String uri)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("NAMESPACE", 50);
+        logMetacat.info("NAMESPACE");
 
         namespaces.put(prefix, uri);
     }
@@ -273,9 +276,9 @@
         // for element <eml:eml...> qname is "eml:eml", local name is "eml"
         // for element <acl....> both qname and local name is "eml"
         // uri is namesapce
-        MetaCatUtil.debugMessage("Start ELEMENT(qName) " + qName, 50);
-        MetaCatUtil.debugMessage("Start ELEMENT(localName) " + localName, 50);
-        MetaCatUtil.debugMessage("Start ELEMENT(uri) " + uri, 50);
+        logMetacat.info("Start ELEMENT(qName) " + qName);
+        logMetacat.info("Start ELEMENT(localName) " + localName);
+        logMetacat.info("Start ELEMENT(uri) " + uri);
 
         DBSAXNode parentNode = null;
         DBSAXNode currentNode = null;
@@ -316,13 +319,13 @@
                 } else {
                     doctype = docname;
                 }
-                MetaCatUtil.debugMessage("DOCNAME-a: " + docname, 30);
-                MetaCatUtil.debugMessage("DOCTYPE-a: " + doctype, 30);
+                logMetacat.info("DOCNAME-a: " + docname);
+                logMetacat.info("DOCTYPE-a: " + doctype);
             } else if (doctype == null) {
                 // because docname is not null and it is declared in dtd
                 // so could not be in schema, no namespace
                 doctype = docname;
-                MetaCatUtil.debugMessage("DOCTYPE-b: " + doctype, 30);
+                logMetacat.info("DOCTYPE-b: " + doctype);
             }
            
             rootNode.writeNodename(docname);
@@ -440,6 +443,7 @@
     }
 
     public void runIndexingThread(){
+    	
         boolean useXMLIndex =
             (new Boolean(MetaCatUtil.getOption("usexmlindex"))).booleanValue();
         if (useXMLIndex && !isRevisionDoc) {
@@ -447,8 +451,8 @@
                 xmlIndex.start();
             } catch (NullPointerException e) {
                 xmlIndex = null;
-                MetaCatUtil.debugMessage("Error in DBSAXHandler.runIndexingThread() "
-                        + e.getMessage(), 20);
+                logMetacat.error("Error in DBSAXHandler.runIndexingThread() "
+                        + e.getMessage());
             }
         }
     }
@@ -472,8 +476,8 @@
              currentDocument.buildIndex();
             }
         } catch (Exception e) {
-            MetaCatUtil.debugMessage("Error in DBSAXHandler.run "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in DBSAXHandler.run "
+                    + e.getMessage());
         }
     }
 
@@ -516,8 +520,8 @@
                 ResultSet doccheckRS = xmlDocCheck.getResultSet();
                 boolean tableHasRows = doccheckRS.next();
                 if (tableHasRows) {
-                    MetaCatUtil.debugMessage(
-                            "=========== found the correct document", 35);
+                    logMetacat.info(
+                            "=========== found the correct document");
                     inxmldoc = true;
                 }
                 doccheckRS.close();
@@ -534,8 +538,8 @@
                 //dbconn.close();
             } catch (SQLException sqle) {
             }
-            MetaCatUtil.debugMessage("Error in DBSAXHandler.checkDocumentTable "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in DBSAXHandler.checkDocumentTable "
+                    + e.getMessage());
 
         } finally {
             DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -546,7 +550,7 @@
     /** SAX Handler that is called for each XML text node */
     public void characters(char[] cbuf, int start, int len) throws SAXException
     {
-        MetaCatUtil.debugMessage("CHARACTERS", 50);
+        logMetacat.info("CHARACTERS");
         // buffer all text nodes for same element. This is for text was splited
         // into different nodes
         textBuffer.append(new String(cbuf, start, len));
@@ -555,9 +559,8 @@
         // if text buffer .size is greater than max, write it to db.
         // so we can save memory
         if (textBuffer.length() > MAXDATACHARS) {
-            MetaCatUtil.debugMessage("Write text into DB in charaters"
-                    + " when text buffer size is greater than maxmum number",
-                    50);
+            logMetacat.info("Write text into DB in charaters"
+                    + " when text buffer size is greater than maxmum number");
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
                     currentNode);
@@ -576,7 +579,7 @@
         // When validation is turned "on", white spaces are reported here
         // When validation is turned "off" white spaces are not reported here,
         // but through characters() callback
-        MetaCatUtil.debugMessage("IGNORABLEWHITESPACE", 50);
+        logMetacat.info("IGNORABLEWHITESPACE");
 
         DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
         String data = null;
@@ -612,7 +615,7 @@
     public void processingInstruction(String target, String data)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("PI", 50);
+        logMetacat.info("PI");
         DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
         endNodeId = currentNode.writeChildNodeToDB("PI", target, data, docid);
     }
@@ -621,7 +624,7 @@
     public void endElement(String uri, String localName, String qName)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("End ELEMENT " + qName, 50);
+        logMetacat.info("End ELEMENT " + qName);
 
         // write buffered text nodes into db (so no splited)
         DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
@@ -630,7 +633,7 @@
         // into the buffer, write the buffer to data base. The reason we put
         // write database here is for xerces some time split text node
         if (hitTextNode) {
-            MetaCatUtil.debugMessage("Write text into DB in End Element", 50);
+            logMetacat.info("Write text into DB in End Element");
             endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
                     currentNode);
 
@@ -688,11 +691,11 @@
         // we don't put the dtd node into node stack
         DBSAXNode dtdNode = new DBSAXNode(connection, name, publicId, systemId,
                 currentNode, currentNode.getRootNodeID(), docid);
-        MetaCatUtil.debugMessage("Start DTD", 50);
-        MetaCatUtil.debugMessage("Setting processingDTD to true", 50);
-        MetaCatUtil.debugMessage("DOCNAME: " + docname, 50);
-        MetaCatUtil.debugMessage("DOCTYPE: " + doctype, 50);
-        MetaCatUtil.debugMessage("  SYSID: " + systemid, 50);
+        logMetacat.info("Start DTD");
+        logMetacat.info("Setting processingDTD to true");
+        logMetacat.info("DOCNAME: " + docname);
+        logMetacat.info("DOCTYPE: " + doctype);
+        logMetacat.info("  SYSID: " + systemid);
     }
 
     /**
@@ -702,8 +705,8 @@
     {
 
         processingDTD = false;
-        MetaCatUtil.debugMessage("Setting processingDTD to false", 50);
-        MetaCatUtil.debugMessage("end DTD", 50);
+        logMetacat.info("Setting processingDTD to false");
+        logMetacat.info("end DTD");
     }
 
     /**
@@ -711,7 +714,7 @@
      */
     public void comment(char[] ch, int start, int length) throws SAXException
     {
-        MetaCatUtil.debugMessage("COMMENT", 50);
+        logMetacat.info("COMMENT");
         if (!processingDTD) {
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             endNodeId = currentNode.writeChildNodeToDB("COMMENT", null,
@@ -724,7 +727,7 @@
      */
     public void startCDATA() throws SAXException
     {
-        MetaCatUtil.debugMessage("start CDATA", 50);
+        logMetacat.info("start CDATA");
     }
 
     /**
@@ -732,7 +735,7 @@
      */
     public void endCDATA() throws SAXException
     {
-        MetaCatUtil.debugMessage("end CDATA", 50);
+        logMetacat.info("end CDATA");
     }
 
     /**
@@ -740,7 +743,7 @@
      */
     public void startEntity(String name) throws SAXException
     {
-        MetaCatUtil.debugMessage("start ENTITY: " + name, 50);
+        logMetacat.info("start ENTITY: " + name);
         //System.out.println("start ENTITY: " + name);
         if (name.equals("[dtd]")) {
             processingDTD = true;
@@ -752,7 +755,7 @@
      */
     public void endEntity(String name) throws SAXException
     {
-        MetaCatUtil.debugMessage("end ENTITY: " + name, 50);
+        logMetacat.info("end ENTITY: " + name);
         //System.out.println("end ENTITY: " + name);
         if (name.equals("[dtd]")) {
             processingDTD = false;
@@ -766,7 +769,7 @@
             throws org.xml.sax.SAXException
     {
         //System.out.println("ELEMENTDECL: " + name + " " + model);
-        MetaCatUtil.debugMessage("ELEMENTDECL: " + name + " " + model, 50);
+        logMetacat.info("ELEMENTDECL: " + name + " " + model);
     }
 
     /**
@@ -779,8 +782,8 @@
         //System.out.println("ATTRIBUTEDECL: " + eName + " "
         //                        + aName + " " + type + " " + valueDefault + " "
         //                        + value);
-        MetaCatUtil.debugMessage("ATTRIBUTEDECL: " + eName + " " + aName + " "
-                + type + " " + valueDefault + " " + value, 50);
+        logMetacat.info("ATTRIBUTEDECL: " + eName + " " + aName + " "
+                + type + " " + valueDefault + " " + value);
     }
 
     /**
@@ -790,7 +793,7 @@
             throws org.xml.sax.SAXException
     {
         //System.out.println("INTERNENTITYDECL: " + name + " " + value);
-        MetaCatUtil.debugMessage("INTERNENTITYDECL: " + name + " " + value, 50);
+        logMetacat.info("INTERNENTITYDECL: " + name + " " + value);
     }
 
     /**
@@ -801,8 +804,8 @@
     {
         //System.out.println("EXTERNENTITYDECL: " + name + " " + publicId
         //                              + " " + systemId);
-        MetaCatUtil.debugMessage("EXTERNENTITYDECL: " + name + " " + publicId
-                + " " + systemId, 50);
+        logMetacat.info("EXTERNENTITYDECL: " + name + " " + publicId
+                + " " + systemId);
         // it processes other external entity, not the DTD;
         // it doesn't signal for the DTD here
         processingDTD = false;
@@ -817,7 +820,7 @@
      */
     public void fatalError(SAXParseException exception) throws SAXException
     {
-        MetaCatUtil.debugMessage("FATALERROR: " + exception.getMessage(), 50);
+        logMetacat.fatal("FATALERROR: " + exception.getMessage());
         throw (new SAXException("Fatal processing error.", exception));
     }
 
@@ -826,7 +829,7 @@
      */
     public void error(SAXParseException exception) throws SAXException
     {
-        MetaCatUtil.debugMessage("ERROR: " + exception.getMessage(), 50);
+        logMetacat.error("ERROR: " + exception.getMessage());
         throw (new SAXException("Error in processing EML.", exception));
     }
 
@@ -835,7 +838,7 @@
      */
     public void warning(SAXParseException exception) throws SAXException
     {
-        MetaCatUtil.debugMessage("WARNING: " + exception.getMessage(), 50);
+        logMetacat.warn("WARNING: " + exception.getMessage());
         throw (new SAXException("Warning.", exception));
     }
 
@@ -896,7 +899,7 @@
 
         // if there are some cotent in buffer, write it
         if (bufferSize > 0) {
-            MetaCatUtil.debugMessage("Write text into DB", 50);
+            logMetacat.info("Write text into DB");
             // This loop deals with the case where there are more characters
             // than can fit in a single database text field (limit is
             // MAXDATACHARS). If the text to be inserted exceeds MAXDATACHARS,
Index: src/edu/ucsb/nceas/metacat/Eml200SAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/Eml200SAXHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/Eml200SAXHandler.java	(revision 2663)
@@ -45,6 +45,7 @@
 import java.util.Stack;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -281,6 +282,8 @@
 
     private static final String DISTRIBUTION = "distribution";
 
+    private Logger logMetacat = Logger.getLogger(Eml200SAXHandler.class);   	   	
+    
     /**
      * Construct an instance of the handler class In this constructor, user can
      * specify the version need to upadate
@@ -345,8 +348,8 @@
         }
         catch (Exception e)
         {
-            MetaCatUtil.debugMessage("erorr in Eml200SAXHanlder is "
-                                     +e.getMessage(), 30);
+            logMetacat.error("erorr in Eml200SAXHanlder is "
+                                     +e.getMessage());
             throw new SAXException(e.getMessage());
         }
     }
@@ -560,9 +563,9 @@
         // for element <eml:eml...> qname is "eml:eml", local name is "eml"
         // for element <acl....> both qname and local name is "eml"
         // uri is namesapce
-        MetaCatUtil.debugMessage("Start ELEMENT(qName) " + qName, 10);
-        MetaCatUtil.debugMessage("Start ELEMENT(localName) " + localName, 10);
-        MetaCatUtil.debugMessage("Start ELEMENT(uri) " + uri, 10);
+        logMetacat.info("Start ELEMENT(qName) " + qName);
+        logMetacat.info("Start ELEMENT(localName) " + localName);
+        logMetacat.info("Start ELEMENT(uri) " + uri);
 
         DBSAXNode parentNode = null;
         DBSAXNode currentNode = null;
@@ -673,13 +676,13 @@
                     } else {
                         doctype = docname;
                     }
-                    MetaCatUtil.debugMessage("DOCNAME-a: " + docname, 30);
-                    MetaCatUtil.debugMessage("DOCTYPE-a: " + doctype, 30);
+                    logMetacat.info("DOCNAME-a: " + docname);
+                    logMetacat.info("DOCTYPE-a: " + doctype);
                 } else if (doctype == null) {
                     // because docname is not null and it is declared in dtd
                     // so could not be in schema, no namespace
                     doctype = docname;
-                    MetaCatUtil.debugMessage("DOCTYPE-b: " + doctype, 30);
+                    logMetacat.info("DOCTYPE-b: " + doctype);
                 }
                 rootNode.writeNodename(docname);
                 //System.out.println("here!!!!!!!!!!!!!!!!!!1");
@@ -833,7 +836,7 @@
                   // described element. If it has a descirbed element,
                   // this code would hurt any thing
                   processAdditionalAccess = true;
-                  MetaCatUtil.debugMessage("assing process addtional access true when meet access", 20);
+                  logMetacat.warn("accessing process addtional access true when meet access");
                 }
 
 
@@ -934,7 +937,7 @@
                         localName, prefix, MetaCatUtil.normalize(null));
               storedAccessNodeStack.push(nodeElement);
               processAdditionalAccess = true;
-              MetaCatUtil.debugMessage("set processAdditonalAccess ture when meet describe", 20);
+              logMetacat.warn("set processAdditonalAccess ture when meet describe");
             }
             else if (inAddtionalMetaData && processAdditionalAccess &&
                      parentNode.getTagName().equals(ADDITIONALMETADATA) &&
@@ -950,7 +953,7 @@
                // If additionalMetadata has access element, the flag will be
                // terminated in endElement
                processAdditionalAccess = false;
-               MetaCatUtil.debugMessage("set processAddtionAccess false if the there is no access in additional", 20);
+               logMetacat.warn("set processAddtionAccess false if the there is no access in additional");
             }
             else if (currentNode.getTagName().equals(DISTRIBUTION) &&
                      !inAddtionalMetaData)
@@ -1005,8 +1008,8 @@
             inlineDataNameSpace = null;
             inlineDataNameSpace = new Hashtable();
             //write inline data into file
-            MetaCatUtil.debugMessage("the inline element data is: "
-                    + inlineElements.toString(), 50);
+            logMetacat.info("the inline element data is: "
+                    + inlineElements.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineElements);
         }//else
         //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -1018,7 +1021,7 @@
     /** SAX Handler that is called for each XML text node */
     public void characters(char[] cbuf, int start, int len) throws SAXException
     {
-        MetaCatUtil.debugMessage("CHARACTERS", 50);
+        logMetacat.info("CHARACTERS");
         if (!handleInlineData) {
             // buffer all text nodes for same element. This is for text was
             // splited
@@ -1030,11 +1033,8 @@
             // so we can save memory
             if (textBuffer.length() >= MAXDATACHARS)
             {
-                MetaCatUtil
-                        .debugMessage(
-                                "Write text into DB in charaters"
-                                        + " when text buffer size is greater than maxmum number",
-                                50);
+                logMetacat.info("Write text into DB in charaters"
+                           + " when text buffer size is greater than maxmum number");
                 DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
                 endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
                         currentNode);
@@ -1058,9 +1058,9 @@
             // we don't need to buffered it.
             StringBuffer inlineText = new StringBuffer();
             inlineText.append(new String(cbuf, start, len));
-            MetaCatUtil.debugMessage(
+            logMetacat.info(
                     "The inline text data write into file system: "
-                            + inlineText.toString(), 50);
+                            + inlineText.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineText);
         }
     }
@@ -1069,7 +1069,7 @@
     public void endElement(String uri, String localName, String qName)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("End ELEMENT " + qName, 50);
+        logMetacat.info("End ELEMENT " + qName);
 
         // when close inline element
         //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -1079,7 +1079,7 @@
             // Get the node from the stack
             DBSAXNode currentNode = (DBSAXNode) nodeStack.pop();
             String currentTag = currentNode.getTagName();
-            MetaCatUtil.debugMessage("End of inline data", 35);
+            logMetacat.info("End of inline data");
             // close file writer
             try
             {
@@ -1109,9 +1109,9 @@
                   }
                   else
                   {
-                    MetaCatUtil.debugMessage(
+                    logMetacat.info(
                                "inline data was changed by a user"
-                                       + " who doesn't have permission", 30);
+                                       + " who doesn't have permission");
                     throw new SAXException(PERMISSIONERROR);
 
                   }
@@ -1121,9 +1121,9 @@
                   // user get the inline data
                   if (modifiedInlineData(distributionId, inlineDataFileName))
                   {
-                    MetaCatUtil.debugMessage(
+                    logMetacat.info(
                                 "inline data was changed by a user"
-                                        + " who doesn't have permission", 30);
+                                        + " who doesn't have permission");
                     throw new SAXException(PERMISSIONERROR);
                   }//if
                 }//else
@@ -1262,8 +1262,8 @@
                 }//else if
                 // write text to db if it is not inline data
 
-                MetaCatUtil.debugMessage(
-                            "Write text into DB in End Element", 50);
+                logMetacat.info(
+                            "Write text into DB in End Element");
 
                  // write text node into db
                  endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
@@ -1411,8 +1411,8 @@
             endElement.append("</");
             endElement.append(qName);
             endElement.append(">");
-            MetaCatUtil.debugMessage("inline endElement: "
-                    + endElement.toString(), 50);
+            logMetacat.info("inline endElement: "
+                    + endElement.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, endElement);
         }
         //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -1438,9 +1438,9 @@
        {
          return modified;
        }
-       MetaCatUtil.debugMessage("in handle inline data", 35);
-       MetaCatUtil.debugMessage("the inline data file name from xml_access is: "
-                                    + oldInlineInternalFileName, 40);
+       logMetacat.info("in handle inline data");
+       logMetacat.info("the inline data file name from xml_access is: "
+                                    + oldInlineInternalFileName);
 
        try
        {
@@ -1514,7 +1514,7 @@
      */
     public void comment(char[] ch, int start, int length) throws SAXException
     {
-        MetaCatUtil.debugMessage("COMMENT", 50);
+        logMetacat.info("COMMENT");
         if (!handleInlineData) {
             if (!processingDTD) {
                 DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
@@ -1547,8 +1547,8 @@
             inlineComment.append("<!--");
             inlineComment.append(new String(ch, start, length));
             inlineComment.append("-->");
-            MetaCatUtil.debugMessage("inline data comment: "
-                    + inlineComment.toString(), 50);
+            logMetacat.info("inline data comment: "
+                    + inlineComment.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineComment);
         }
     }
@@ -1562,7 +1562,7 @@
     public void processingInstruction(String target, String data)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("PI", 50);
+        logMetacat.info("PI");
         if (!handleInlineData) {
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             endNodeId = currentNode.writeChildNodeToDB("PI", target, data,
@@ -1574,8 +1574,8 @@
             inlinePI.append(" ");
             inlinePI.append(data);
             inlinePI.append("?>");
-            MetaCatUtil.debugMessage("inline data pi is: "
-                    + inlinePI.toString(), 50);
+            logMetacat.info("inline data pi is: "
+                    + inlinePI.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlinePI);
         }
     }
@@ -1584,9 +1584,9 @@
     public void startPrefixMapping(String prefix, String uri)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("NAMESPACE", 50);
-        MetaCatUtil.debugMessage("NAMESPACE prefix "+prefix, 50);
-        MetaCatUtil.debugMessage("NAMESPACE uri "+uri, 50);
+        logMetacat.info("NAMESPACE");
+        logMetacat.info("NAMESPACE prefix "+prefix);
+        logMetacat.info("NAMESPACE uri "+uri);
         if (!handleInlineData) {
             namespaces.put(prefix, uri);
         } else {
@@ -1604,7 +1604,7 @@
         // When validation is turned "on", white spaces are reported here
         // When validation is turned "off" white spaces are not reported here,
         // but through characters() callback
-        MetaCatUtil.debugMessage("IGNORABLEWHITESPACE", 50);
+        logMetacat.info("IGNORABLEWHITESPACE");
         if (!handleInlineData) {
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             String data = null;
@@ -1663,7 +1663,7 @@
     /** SAX Handler that receives notification of end of the document */
     public void endDocument() throws SAXException
     {
-        MetaCatUtil.debugMessage("end Document", 50);
+        logMetacat.info("end Document");
         if (needCheckingAccessModule)
         {
           compareAllAccessModules();
@@ -1767,7 +1767,7 @@
   {
       // make sure stack1 and stack2 are not empty
       if (stack1.isEmpty() || stack2.isEmpty()) {
-          MetaCatUtil.debugMessage("Because stack is empty!", 35);
+          logMetacat.info("Because stack is empty!");
           throw new SAXException(UPDATEACCESSERROR);
       }
       // go throw two stacks and compare every element
@@ -1781,16 +1781,14 @@
               record2 = (NodeRecord) stack2.pop();
           } catch (EmptyStackException ee) {
 
-              MetaCatUtil.debugMessage(
-                      "Node stack2 is empty but stack1 isn't!", 35);
+              logMetacat.error(
+                      "Node stack2 is empty but stack1 isn't!");
               throw new SAXException(UPDATEACCESSERROR);
           }
           // if two records are not same throw a exception
           if (!record1.contentEquals(record2)) {
-              MetaCatUtil
-                      .debugMessage(
-                              "Two records from new and old stack are not "
-                                      + "same!" + record1 + "--" +record2, 30);
+              logMetacat.info("Two records from new and old stack are not "
+                                      + "same!" + record1 + "--" +record2);
               throw new SAXException(UPDATEACCESSERROR);
           }//if
       }//while
@@ -1798,9 +1796,9 @@
       // now stack1 is empty and we should make sure stack2 is empty too
       if (!stack2.isEmpty()) {
 
-          MetaCatUtil.debugMessage(
+          logMetacat.info(
                   "stack2 still have some elements while stack1 "
-                          + "is empty! ", 30);
+                          + "is empty! ");
           throw new SAXException(UPDATEACCESSERROR);
       }//if
   }//comparingNodeStacks
@@ -1836,8 +1834,8 @@
    {
      if (access == null)
      {
-       MetaCatUtil.debugMessage("access module is null in " +
-                                "resolveAccessRulesReference", 30);
+       logMetacat.info("access module is null in " +
+                                "resolveAccessRulesReference");
        throw new SAXException("An access modules is null");
      }
      String subTreeId = access.getSubTreeId();
@@ -1966,15 +1964,15 @@
        for (int j = 0; j < describeIdList.size(); j++)
        {
          String subreeid = (String)describeIdList.elementAt(j);
-         MetaCatUtil.debugMessage("describe id in additional access " +
-                                  subreeid, 30);
+         logMetacat.info("describe id in additional access " +
+                                  subreeid);
          // we need to figure out the real id if this subreeid is points to
          // a distribution reference.
          subreeid = resolveDistributionReference(subreeid);
          if (subreeid != null && !subreeid.trim().equals(""))
          {
-           MetaCatUtil.debugMessage("subtree id is "+ subreeid +
-                                    " after resolve reference id", 30 );
+           logMetacat.info("subtree id is "+ subreeid +
+                                    " after resolve reference id" );
            // if this id is for line data, we need to delete the records first
            // then add new records. The key for deleting is subtee id
            if (inlineDistributionIdList.containsKey(subreeid))
@@ -1982,8 +1980,8 @@
              String inlineFileName = (String)
                                         inlineDistributionIdList.get(subreeid);
              deleteSubtreeAccessRule(subreeid);
-             MetaCatUtil.debugMessage("Write inline data access into " +
-                                   "xml_access table for"+ inlineFileName, 30);
+             logMetacat.info("Write inline data access into " +
+                                   "xml_access table for"+ inlineFileName);
              writeGivenAccessRuleIntoDB(permOrder, accessRule,
                                         inlineFileName, subreeid);
            }
@@ -1997,15 +1995,15 @@
              // for online data, the subtree id we set is null.
              // So in xml_access, only the inline data subteeid is not null
              String dataFileName = handleOnlineUrlDataFile(url);
-             MetaCatUtil.debugMessage("The data fileName in online url " +
-                                      dataFileName, 30);
+             logMetacat.info("The data fileName in online url " +
+                                      dataFileName);
              if (dataFileName != null)
              {
                deletePermissionsInAccessTableForDoc(dataFileName);
                writeGivenAccessRuleIntoDB(permOrder, accessRule,
                                           dataFileName, null);
-               MetaCatUtil.debugMessage("Write online data access into " +
-                                   "xml_access table for " + dataFileName, 30);
+               logMetacat.info("Write online data access into " +
+                                   "xml_access table for " + dataFileName);
                // put the id into a hashtalbe. So when we run wirtetop level
                // access, those id will be ignored because they already has
                // additional access rules
@@ -2083,8 +2081,8 @@
           dataId.trim().equals("") || accessRules == null ||
           accessRules.isEmpty())
       {
-        MetaCatUtil.debugMessage("The access object is null and tried to " +
-                                  " write to xml_access table", 30);
+        logMetacat.info("The access object is null and tried to " +
+                                  " write to xml_access table");
         throw new SAXException("The access object is null");
       }
        // get rid of rev from dataId
@@ -2104,16 +2102,13 @@
            connection.increaseUsageCount(1);
            // Bind the values to the query
            pstmt.setString(1, dataId);
-           MetaCatUtil.debugMessage("Docid in accesstable: " + docid, 35);
+           logMetacat.info("Docid in accesstable: " + docid);
            pstmt.setString(6, docid);
-           MetaCatUtil.debugMessage("Accessfileid in accesstable: " + docid,
-                   35);
+           logMetacat.info("Accessfileid in accesstable: " + docid);
            pstmt.setString(5, permOrder);
-           MetaCatUtil.debugMessage("PermOder in accesstable: " + permOrder,
-                   35);
+           logMetacat.info("PermOder in accesstable: " + permOrder);
            pstmt.setString(7, subTreeId);
-           MetaCatUtil.debugMessage("subtree id in accesstable: " + subTreeId,
-                   35);
+           logMetacat.info("subtree id in accesstable: " + subTreeId);
            // if it is not top level, set s id
 
            //Vector accessRules = accessSection.getAccessRules();
@@ -2124,11 +2119,11 @@
                String permType = rule.getPermissionType();
                int permission = rule.getPermission();
                pstmt.setInt(3, permission);
-               MetaCatUtil.debugMessage("permission in accesstable: "
-                       + permission, 35);
+               logMetacat.info("permission in accesstable: "
+                       + permission);
                pstmt.setString(4, permType);
-               MetaCatUtil.debugMessage(
-                       "Permtype in accesstable: " + permType, 35);
+               logMetacat.info(
+                       "Permtype in accesstable: " + permType);
                // go through every principle in rule
                Vector nameVector = rule.getPrincipal();
                for (int j = 0; j < nameVector.size(); j++)
@@ -2135,8 +2130,8 @@
                {
                    String prName = (String) nameVector.elementAt(j);
                    pstmt.setString(2, prName);
-                   MetaCatUtil.debugMessage("Principal in accesstable: "
-                           + prName, 35);
+                   logMetacat.info("Principal in accesstable: "
+                           + prName);
                    pstmt.execute();
                }//for
            }//for
@@ -2257,8 +2252,8 @@
         if (accessSection == null)
         {
 
-          MetaCatUtil.debugMessage("Access object is null and tried to write "+
-                                   "into access subtree table", 30);
+          logMetacat.info("Access object is null and tried to write "+
+                                   "into access subtree table");
           throw new SAXException("The access object is null to write access " +
                                  "sbutree");
         }
@@ -2306,21 +2301,19 @@
 
             // Bind the values to the query
             pstmt.setString(1, docid);
-            MetaCatUtil.debugMessage("Docid in access-subtreetable: " + docid,
-                    35);
+            logMetacat.info("Docid in access-subtreetable: " + docid);
             pstmt.setInt(2, (new Integer(revision)).intValue());
-            MetaCatUtil.debugMessage("rev in accesssubtreetable: " + revision,
-                    35);
+            logMetacat.info("rev in accesssubtreetable: " + revision);
             pstmt.setString(3, level);
-            MetaCatUtil.debugMessage("contorl level in access-subtree table: "
-                    + level, 35);
+            logMetacat.info("contorl level in access-subtree table: "
+                    + level);
             pstmt.setString(4, sectionId);
-            MetaCatUtil.debugMessage("Subtree id in access-subtree table: "
-                    + sectionId, 35);
+            logMetacat.info("Subtree id in access-subtree table: "
+                    + sectionId);
             pstmt.setLong(5, startNodeId);
-            MetaCatUtil.debugMessage("Start node id is: " + startNodeId, 35);
+            logMetacat.info("Start node id is: " + startNodeId);
             pstmt.setLong(6, endNodeId);
-            MetaCatUtil.debugMessage("End node id is: " + endNodeId, 35);
+            logMetacat.info("End node id is: " + endNodeId);
             pstmt.execute();
             pstmt.close();
         }//try
@@ -2378,7 +2371,7 @@
          * File inlineDataDirectory = new File(path);
          */
         String newFile = path + "/" + fileName;
-        MetaCatUtil.debugMessage("inline file name: " + newFile, 30);
+        logMetacat.info("inline file name: " + newFile);
         try {
             // true means append
             writer = new FileWriter(newFile, true);
@@ -2447,8 +2440,7 @@
         } catch (Exception e) {
             throw new McdbException(e.getMessage());
         }
-        MetaCatUtil.debugMessage("the inline data retrieve from file: " + data,
-                50);
+        logMetacat.info("the inline data retrieve from file: " + data);
         return same;
     }
 
@@ -2473,9 +2465,9 @@
       throw new SAXException("Could not copy inline file from old one to new "+
                               "one because can't find old file name");
     }
-    MetaCatUtil.debugMessage("in handle inline data", 35);
-    MetaCatUtil.debugMessage("the inline data file name from xml_access is: "
-                                 + oldInlineInternalFileName, 40);
+    logMetacat.info("in handle inline data");
+    logMetacat.info("the inline data file name from xml_access is: "
+                                 + oldInlineInternalFileName);
 
     String path = MetaCatUtil.getOption("inlinedatafilepath");
     // the new file name will look like path/docid.rev.2
@@ -2659,7 +2651,7 @@
      */
     private String handleOnlineUrlDataFile(String url) throws SAXException
     {
-      MetaCatUtil.debugMessage("The url is "+ url, 10);
+      logMetacat.warn("The url is "+ url);
       String docid = null;
       // if the url is not a ecogrid protocol, null will be getten
       String accessionNumber =
@@ -2692,9 +2684,9 @@
         }//try
         catch(Exception e)
         {
-          MetaCatUtil.debugMessage("Eorr in " +
+          logMetacat.error("Error in " +
                                 "Eml200SAXHanlder.handleOnlineUrlDataFile is " +
-                                 e.getMessage(), 30);
+                                 e.getMessage());
           throw new SAXException(e.getMessage());
         }
       }
@@ -2710,20 +2702,18 @@
         try {
             elementNode = (NodeRecord) unchangableNodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil
-                    .debugMessage("Node stack is empty for element data", 35);
+            logMetacat.error("Node stack is empty for element data");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage("current node type from xml is ELEMENT", 40);
-        MetaCatUtil.debugMessage("node type from stack: "
-                + elementNode.getNodeType(), 40);
-        MetaCatUtil.debugMessage("node name from xml document: " + localName,
-                40);
-        MetaCatUtil.debugMessage("node name from stack: "
-                + elementNode.getNodeName(), 40);
-        MetaCatUtil.debugMessage("node data from stack: "
-                + elementNode.getNodeData(), 40);
-        MetaCatUtil.debugMessage("node id is: " + elementNode.getNodeId(), 40);
+        logMetacat.info("current node type from xml is ELEMENT");
+        logMetacat.info("node type from stack: "
+                + elementNode.getNodeType());
+        logMetacat.info("node name from xml document: " + localName);
+        logMetacat.info("node name from stack: "
+                + elementNode.getNodeName());
+        logMetacat.info("node data from stack: "
+                + elementNode.getNodeData());
+        logMetacat.info("node id is: " + elementNode.getNodeId());
         // if this node is not element or local name not equal or name space
         // not
         // equals, throw an exception
@@ -2731,19 +2721,17 @@
                 || !localName.equals(elementNode.getNodeName()))
         //  (uri != null && !uri.equals(elementNode.getNodePrefix())))
         {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage("current node type from xml is ELEMENT",
-                    40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + elementNode.getNodeType(), 40);
-            MetaCatUtil.debugMessage("node name from xml document: "
-                    + localName, 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + elementNode.getNodeName(), 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + elementNode.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node id is: " + elementNode.getNodeId(),
-                    40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info("current node type from xml is ELEMENT");
+            logMetacat.info("node type from stack: "
+                    + elementNode.getNodeType());
+            logMetacat.info("node name from xml document: "
+                    + localName);
+            logMetacat.info("node name from stack: "
+                    + elementNode.getNodeName());
+            logMetacat.info("node data from stack: "
+                    + elementNode.getNodeData());
+            logMetacat.info("node id is: " + elementNode.getNodeId());
             throw new SAXException(error);
         }
 
@@ -2755,8 +2743,8 @@
             try {
                 nameNode = (NodeRecord) unchangableNodeStack.pop();
             } catch (EmptyStackException ee) {
-                MetaCatUtil.debugMessage(
-                        "Node stack is empty for namespace data", 35);
+                logMetacat.error(
+                        "Node stack is empty for namespace data");
                 throw new SAXException(error);
             }
 
@@ -2765,21 +2753,20 @@
             if (!nameNode.getNodeType().equals("NAMESPACE")
                     || !prefixName.equals(nameNode.getNodeName())
                     || !nameSpaceUri.equals(nameNode.getNodeData())) {
-                MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-                MetaCatUtil.debugMessage(
-                        "current node type from xml is NAMESPACE", 40);
-                MetaCatUtil.debugMessage("node type from stack: "
-                        + nameNode.getNodeType(), 40);
-                MetaCatUtil.debugMessage("current node name from xml is: "
-                        + prefixName, 40);
-                MetaCatUtil.debugMessage("node name from stack: "
-                        + nameNode.getNodeName(), 40);
-                MetaCatUtil.debugMessage("current node data from xml is: "
-                        + nameSpaceUri, 40);
-                MetaCatUtil.debugMessage("node data from stack: "
-                        + nameNode.getNodeData(), 40);
-                MetaCatUtil.debugMessage("node id is: " + nameNode.getNodeId(),
-                        40);
+                logMetacat.info("Inconsistence happend: ");
+                logMetacat.info(
+                        "current node type from xml is NAMESPACE");
+                logMetacat.info("node type from stack: "
+                        + nameNode.getNodeType());
+                logMetacat.info("current node name from xml is: "
+                        + prefixName);
+                logMetacat.info("node name from stack: "
+                        + nameNode.getNodeName());
+                logMetacat.info("current node data from xml is: "
+                        + nameSpaceUri);
+                logMetacat.info("node data from stack: "
+                        + nameNode.getNodeData());
+                logMetacat.info("node id is: " + nameNode.getNodeId());
                 throw new SAXException(error);
             }
 
@@ -2792,45 +2779,43 @@
                 attriNode = (NodeRecord) unchangableNodeStack.pop();
 
             } catch (EmptyStackException ee) {
-                MetaCatUtil.debugMessage(
-                        "Node stack is empty for attribute data", 35);
+                logMetacat.error(
+                        "Node stack is empty for attribute data");
                 throw new SAXException(error);
             }
             String attributeName = attributes.getQName(i);
             String attributeValue = attributes.getValue(i);
-            MetaCatUtil.debugMessage(
-                    "current node type from xml is ATTRIBUTE ", 40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + attriNode.getNodeType(), 40);
-            MetaCatUtil.debugMessage("current node name from xml is: "
-                    + attributeName, 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + attriNode.getNodeName(), 40);
-            MetaCatUtil.debugMessage("current node data from xml is: "
-                    + attributeValue, 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + attriNode.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node id  is: " + attriNode.getNodeId(),
-                    40);
+            logMetacat.info(
+                    "current node type from xml is ATTRIBUTE ");
+            logMetacat.info("node type from stack: "
+                    + attriNode.getNodeType());
+            logMetacat.info("current node name from xml is: "
+                    + attributeName);
+            logMetacat.info("node name from stack: "
+                    + attriNode.getNodeName());
+            logMetacat.info("current node data from xml is: "
+                    + attributeValue);
+            logMetacat.info("node data from stack: "
+                    + attriNode.getNodeData());
+            logMetacat.info("node id  is: " + attriNode.getNodeId());
 
             if (!attriNode.getNodeType().equals("ATTRIBUTE")
                     || !attributeName.equals(attriNode.getNodeName())
                     || !attributeValue.equals(attriNode.getNodeData())) {
-                MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-                MetaCatUtil.debugMessage(
-                        "current node type from xml is ATTRIBUTE ", 40);
-                MetaCatUtil.debugMessage("node type from stack: "
-                        + attriNode.getNodeType(), 40);
-                MetaCatUtil.debugMessage("current node name from xml is: "
-                        + attributeName, 40);
-                MetaCatUtil.debugMessage("node name from stack: "
-                        + attriNode.getNodeName(), 40);
-                MetaCatUtil.debugMessage("current node data from xml is: "
-                        + attributeValue, 40);
-                MetaCatUtil.debugMessage("node data from stack: "
-                        + attriNode.getNodeData(), 40);
-                MetaCatUtil.debugMessage("node is: " + attriNode.getNodeId(),
-                        40);
+                logMetacat.info("Inconsistence happend: ");
+                logMetacat.info(
+                        "current node type from xml is ATTRIBUTE ");
+                logMetacat.info("node type from stack: "
+                        + attriNode.getNodeType());
+                logMetacat.info("current node name from xml is: "
+                        + attributeName);
+                logMetacat.info("node name from stack: "
+                        + attriNode.getNodeName());
+                logMetacat.info("current node data from xml is: "
+                        + attributeValue);
+                logMetacat.info("node data from stack: "
+                        + attriNode.getNodeData());
+                logMetacat.info("node is: " + attriNode.getNodeId());
                 throw new SAXException(error);
             }
         }//for
@@ -2846,35 +2831,32 @@
         try {
             node = (NodeRecord) nodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil.debugMessage(
-                    "Node stack is empty for text data in startElement", 35);
+            logMetacat.error(
+                    "Node stack is empty for text data in startElement");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage(
-                "current node type from xml is TEXT in start element", 40);
-        MetaCatUtil.debugMessage("node type from stack: " + node.getNodeType(),
-                40);
-        MetaCatUtil.debugMessage("current node data from xml is: "
-                + text.toString(), 40);
-        MetaCatUtil.debugMessage("node data from stack: " + node.getNodeData(),
-                40);
-        MetaCatUtil.debugMessage("node name from stack: " + node.getNodeName(),
-                40);
-        MetaCatUtil.debugMessage("node is: " + node.getNodeId(), 40);
+        logMetacat.info(
+                "current node type from xml is TEXT in start element");
+        logMetacat.info("node type from stack: " + node.getNodeType());
+        logMetacat.info("current node data from xml is: "
+                + text.toString());
+        logMetacat.info("node data from stack: " + node.getNodeData());
+        logMetacat.info("node name from stack: " + node.getNodeName());
+        logMetacat.info("node is: " + node.getNodeId());
         if (!node.getNodeType().equals("TEXT")
                 || !(text.toString()).equals(node.getNodeData())) {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage(
-                    "current node type from xml is TEXT in start element", 40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + node.getNodeType(), 40);
-            MetaCatUtil.debugMessage("current node data from xml is: "
-                    + text.toString(), 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + node.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + node.getNodeName(), 40);
-            MetaCatUtil.debugMessage("node is: " + node.getNodeId(), 40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info(
+                    "current node type from xml is TEXT in start element");
+            logMetacat.info("node type from stack: "
+                    + node.getNodeType());
+            logMetacat.info("current node data from xml is: "
+                    + text.toString());
+            logMetacat.info("node data from stack: "
+                    + node.getNodeData());
+            logMetacat.info("node name from stack: "
+                    + node.getNodeName());
+            logMetacat.info("node is: " + node.getNodeId());
             throw new SAXException(error);
         }//if
     }
@@ -2887,31 +2869,26 @@
         try {
             node = (NodeRecord) nodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil.debugMessage("the stack is empty for comment data", 32);
+            logMetacat.error("the stack is empty for comment data");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage("current node type from xml is COMMENT", 40);
-        MetaCatUtil.debugMessage("node type from stack: " + node.getNodeType(),
-                40);
-        MetaCatUtil
-                .debugMessage("current node data from xml is: " + string, 40);
-        MetaCatUtil.debugMessage("node data from stack: " + node.getNodeData(),
-                40);
-        MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(), 40);
+        logMetacat.info("current node type from xml is COMMENT");
+        logMetacat.info("node type from stack: " + node.getNodeType());
+        logMetacat.info("current node data from xml is: " + string);
+        logMetacat.info("node data from stack: " + node.getNodeData());
+        logMetacat.info("node is from stack: " + node.getNodeId());
         // if not consistent terminate program and throw a exception
         if (!node.getNodeType().equals("COMMENT")
                 || !string.equals(node.getNodeData())) {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage("current node type from xml is COMMENT",
-                    40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + node.getNodeType(), 40);
-            MetaCatUtil.debugMessage(
-                    "current node data from xml is: " + string, 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + node.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(),
-                    40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info("current node type from xml is COMMENT");
+            logMetacat.info("node type from stack: "
+                    + node.getNodeType());
+            logMetacat.info(
+                    "current node data from xml is: " + string);
+            logMetacat.info("node data from stack: "
+                    + node.getNodeData());
+            logMetacat.info("node is from stack: " + node.getNodeId());
             throw new SAXException(error);
         }//if
     }
@@ -2924,23 +2901,21 @@
        try {
            node = (NodeRecord) nodeStack.pop();
        } catch (EmptyStackException ee) {
-           MetaCatUtil.debugMessage("the stack is empty for whitespace data",
-                   32);
+           logMetacat.error("the stack is empty for whitespace data");
            throw new SAXException(error);
        }
        if (!node.getNodeType().equals("TEXT")
                || !string.equals(node.getNodeData())) {
-           MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-           MetaCatUtil.debugMessage(
-                   "current node type from xml is WHITESPACE TEXT", 40);
-           MetaCatUtil.debugMessage("node type from stack: "
-                   + node.getNodeType(), 40);
-           MetaCatUtil.debugMessage(
-                   "current node data from xml is: " + string, 40);
-           MetaCatUtil.debugMessage("node data from stack: "
-                   + node.getNodeData(), 40);
-           MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(),
-                   40);
+           logMetacat.info("Inconsistence happend: ");
+           logMetacat.info(
+                   "current node type from xml is WHITESPACE TEXT");
+           logMetacat.info("node type from stack: "
+                   + node.getNodeType());
+           logMetacat.info(
+                   "current node data from xml is: " + string);
+           logMetacat.info("node data from stack: "
+                   + node.getNodeData());
+           logMetacat.info("node is from stack: " + node.getNodeId());
            throw new SAXException(error);
        }//if
    }
Index: src/edu/ucsb/nceas/metacat/SchemaLocationResolver.java
===================================================================
--- src/edu/ucsb/nceas/metacat/SchemaLocationResolver.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/SchemaLocationResolver.java	(revision 2663)
@@ -43,6 +43,8 @@
 import java.net.MalformedURLException;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
+
 /**
  * A database aware Class to handle schema location. If namespace is in the
  * xml_catalog table (public_id), the schema location specified in xml document
@@ -63,6 +65,8 @@
   //private String SCHEMATYPE ="Schema"; 
   private String WHITESPACESTRING =" ";                                                         
 
+  private static Logger logMetacat = Logger.getLogger(SchemaLocationResolver.class);
+
   public SchemaLocationResolver()
   {
     createNameSpaceAndLocationStringFromDB();
@@ -83,8 +87,8 @@
    */
   public String getNameSpaceAndLocationString()
   {
-    MetaCatUtil.debugMessage("namespace and location list is: " +
-                             nameSpaceAndLocationString, 30);
+    logMetacat.info("namespace and location list is: " +
+                             nameSpaceAndLocationString);
     return nameSpaceAndLocationString;
   }
   
@@ -115,8 +119,8 @@
        }
        catch(Exception e)
        {
-         MetaCatUtil.debugMessage("Error in SchemaLocation.resolveNameSpace" +
-                                  e.getMessage(), 30);
+         logMetacat.error("Error in SchemaLocation.resolveNameSpace" +
+                                  e.getMessage());
        }
  
     }//if
@@ -174,9 +178,8 @@
     } 
     catch (SQLException e) 
     {
-      MetaCatUtil.debugMessage
-                        ("schemaLocation.createNameSpaceAndLocationString: " + 
-                         e.getMessage(), 30);
+      logMetacat.error("schemaLocation.createNameSpaceAndLocationString: " + 
+                         e.getMessage());
     }
     finally
     {
@@ -186,8 +189,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in schema.createNameSpaceAndLocation "
-                                    + sqlE.getMessage(), 30);
+        logMetacat.error("Error in schema.createNameSpaceAndLocation "
+                                    + sqlE.getMessage());
       }//catch
       DBConnectionPool.returnDBConnection(conn, serialNumber);
     }//finally
@@ -229,9 +232,8 @@
     } 
     catch (SQLException e) 
     {
-      MetaCatUtil.debugMessage
-                        ("schemaLocation.createNameSpaceList: " + 
-                         e.getMessage(), 30);
+      logMetacat.error("schemaLocation.createNameSpaceList: " + 
+                         e.getMessage());
     }
     finally
     {
@@ -241,8 +243,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in schemaLocation.createNameSpaceList: "
-                                    +sqlE.getMessage(), 30);
+        logMetacat.error("Error in schemaLocation.createNameSpaceList: "
+                                    +sqlE.getMessage());
       }//catch
       DBConnectionPool.returnDBConnection(conn, serialNumber);
     }//finally
@@ -322,8 +324,8 @@
       throw new Exception
       ("shemaLocationResolver.uploadSchemaFromURL(): " + e.getMessage());
     } 
-    MetaCatUtil.debugMessage("new schema location is: " + schemaURL + 
-                              filename, 20);
+    logMetacat.warn("new schema location is: " + schemaURL + 
+                              filename);
     return  schemaURL + filename;
   }
 
@@ -364,8 +366,7 @@
     } 
     catch (SQLException e) 
     {
-      MetaCatUtil.debugMessage
-      ("SchemaLocation.egisterSchema(): " + e.getMessage(), 30);
+      logMetacat.error("SchemaLocation.egisterSchema(): " + e.getMessage());
     }
     finally
     {
@@ -375,8 +376,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in SchemaLocation.egisterSchema(): "
-                                    +sqlE.getMessage(), 30);
+        logMetacat.error("Error in SchemaLocation.egisterSchema(): "
+                                    +sqlE.getMessage());
       }//catch
       DBConnectionPool.returnDBConnection(conn, serialNumber);
     }//finally
@@ -403,8 +404,8 @@
       // after white sapce is schema location
       schemaLocation = nameSpaceAndLocation.substring(indexOfWhiteSpace+1);
       // Gebug message
-      MetaCatUtil.debugMessage("Namespace after parsing: " + nameSpace, 30);
-      MetaCatUtil.debugMessage("Location after parsing: " + schemaLocation, 30);
+      logMetacat.info("Namespace after parsing: " + nameSpace);
+      logMetacat.info("Location after parsing: " + schemaLocation);
     } 
   }
   
@@ -415,8 +416,8 @@
        DBConnectionPool pool = DBConnectionPool.getInstance();
        // Print out a empty schema list
        SchemaLocationResolver schema = new SchemaLocationResolver();
-       MetaCatUtil.debugMessage("Namespace and Location String: "+ 
-                                schema.getNameSpaceAndLocationString(), 20);
+       logMetacat.warn("Namespace and Location String: "+ 
+                                schema.getNameSpaceAndLocationString());
        // input a schemalocation
        SchemaLocationResolver schema2 = new SchemaLocationResolver(
                                         "eml://ecoinformatics.org/eml-2.0.0 " +
@@ -429,13 +430,13 @@
        schema3.resolveNameSpace();
        // print out new schema list in db
        SchemaLocationResolver schema4 = new SchemaLocationResolver();
-       MetaCatUtil.debugMessage("Namespace and Location String: "+ 
-                                schema4.getNameSpaceAndLocationString(), 20);
+       logMetacat.warn("Namespace and Location String: "+ 
+                                schema4.getNameSpaceAndLocationString());
      }
      catch(Exception e)
      {
-       MetaCatUtil.debugMessage("erorr in Schemalocation.main: " + 
-                                e.getMessage(), 30);
+       logMetacat.error("erorr in Schemalocation.main: " + 
+                                e.getMessage());
      }
   }
 }
Index: src/edu/ucsb/nceas/metacat/RemoteDocument.java
===================================================================
--- src/edu/ucsb/nceas/metacat/RemoteDocument.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/RemoteDocument.java	(revision 2663)
@@ -29,6 +29,9 @@
 
 import edu.ucsb.nceas.utilities.HttpMessage;
 import javax.servlet.ServletOutputStream;
+
+import org.apache.log4j.Logger;
+
 import java.io.*;
 import java.net.*;
 import java.util.*;
@@ -55,7 +58,7 @@
   private String passWord = null; // The user's passwd
   private String zipEntry = null; // For zip entry
   private String revisionAndDocType; // String to store this info
-
+  private Logger logMetacat = Logger.getLogger(RemoteDocument.class);
   
   /**
    * Constructor of RemoteDcoument
@@ -226,7 +229,7 @@
     String subString = replicationDocHomeServer.substring(0, index);
     // Add https at head and append metacat 
     metacatURL = "https://" + subString +"metacat";
-    MetaCatUtil.debugMessage("metacatURL: "+metacatURL, 30);
+    logMetacat.info("metacatURL: "+metacatURL);
     
     return metacatURL;
     
@@ -292,7 +295,7 @@
     // User specified docid (including revision number
     String specifiedDocId = docIdWithoutRevision + 
                 MetaCatUtil.getOption("accNumSeparator") +revision;
-    MetaCatUtil.debugMessage("The requried docid is: "+ specifiedDocId, 30);
+    logMetacat.info("The requried docid is: "+ specifiedDocId);
     
     // At first login to remote metacat server. 
     logIn(userName, passWord);
@@ -363,7 +366,7 @@
     // User specified docid (including revision number
     String specifiedDocId = docIdWithoutRevision + 
                 MetaCatUtil.getOption("accNumSeparator") +revision;
-    MetaCatUtil.debugMessage("The requried docid is: "+ specifiedDocId, 30);
+    logMetacat.info("The requried docid is: "+ specifiedDocId);
     
     // At first login to remote metacat server.
     logIn(userName, passWord);
@@ -435,7 +438,7 @@
 
     // Now contact metacat and login.
     String response = getMetacatString(prop);
-    MetaCatUtil.debugMessage("Login Message: "+response, 30);
+    logMetacat.info("Login Message: "+response);
   }//login
   
   /**
@@ -449,7 +452,7 @@
     prop.put("qformat", "xml");
     // Send it to remote metacat
     String response = getMetacatString(prop);
-    MetaCatUtil.debugMessage("Logout Message: "+response, 55);
+    logMetacat.debug("Logout Message: "+response);
     // Set cookie to null
     HttpMessage.setCookie(null);
      
@@ -487,8 +490,8 @@
     }
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("Error in RemoteDocument.getMetacatString: "+
-                               e.getMessage(), 30);
+      logMetacat.error("Error in RemoteDocument.getMetacatString: "+
+                               e.getMessage());
       // If there is some exception return null
       return null;
     }
Index: src/edu/ucsb/nceas/metacat/SubTree.java
===================================================================
--- src/edu/ucsb/nceas/metacat/SubTree.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/SubTree.java	(revision 2663)
@@ -34,6 +34,7 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.SAXException;
 
 /**
@@ -47,6 +48,8 @@
   protected long   startNodeId = -1;
   protected long   endNodeId =   -1;
   private Stack  subTreeNodeStack = null;
+  
+  private static Logger logMetacat = Logger.getLogger(SubTree.class);
 
     /**
      * Defualt constructor
@@ -63,13 +66,13 @@
                   long myStartNodeId, long myEndNodeId)
     {
       this.docId = myDocId;
-      MetaCatUtil.debugMessage("Docid of Subtree: " + docId, 30);
+      logMetacat.info("Docid of Subtree: " + docId);
       this.subTreeId = mySubTreeId;
-      MetaCatUtil.debugMessage("id of Subtree: " + subTreeId, 30);
+      logMetacat.info("id of Subtree: " + subTreeId);
       this.startNodeId = myStartNodeId;
-      MetaCatUtil.debugMessage("start node id of Subtree: " + startNodeId, 30);
+      logMetacat.info("start node id of Subtree: " + startNodeId);
       this.endNodeId = myEndNodeId;
-      MetaCatUtil.debugMessage("end node id of subtree: " + endNodeId, 30);
+      logMetacat.info("end node id of subtree: " + endNodeId);
 
     }
 
@@ -100,7 +103,7 @@
     /** Set the a docId */
     public void setDocId(String myId)
     {
-      MetaCatUtil.debugMessage("set doc id: "+myId, 35);
+      logMetacat.info("set doc id: "+myId);
       this.docId = myId;
     }
 
@@ -114,7 +117,7 @@
     /** Set the a subtreeId */
     public void setSubTreeId(String myId)
     {
-      MetaCatUtil.debugMessage("set sub tree id: "+myId, 35);
+      logMetacat.info("set sub tree id: "+myId);
       this.subTreeId = myId;
     }
 
@@ -129,7 +132,7 @@
      */
     public void setStartElementName(String elementName)
     {
-      MetaCatUtil.debugMessage("set start elementname: "+elementName, 35);
+      logMetacat.info("set start elementname: "+elementName);
       this.startElementName = elementName;
     }
 
@@ -144,7 +147,7 @@
     /** Set a start node id */
     public void setStartNodeId(long nodeId)
     {
-      MetaCatUtil.debugMessage("set start node id: "+nodeId, 35);
+      logMetacat.info("set start node id: "+nodeId);
       this.startNodeId = nodeId;
     }
 
@@ -157,7 +160,7 @@
     /** Set a end node id */
     public void setEndNodeId(long nodeId)
     {
-      MetaCatUtil.debugMessage("set end node id: "+nodeId, 35);
+      logMetacat.info("set end node id: "+nodeId);
       this.endNodeId = nodeId;
     }
 
@@ -241,8 +244,8 @@
         }
         catch (SQLException ee)
         {
-          MetaCatUtil.debugMessage("error in SubTree.getSubTreeNodeList 2: "
-                                    +ee.getMessage(), 30);
+          logMetacat.error("error in SubTree.getSubTreeNodeList 2: "
+                                    +ee.getMessage());
         }
         finally
         {
Index: src/edu/ucsb/nceas/metacat/AssociateAccessPolicy.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AssociateAccessPolicy.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AssociateAccessPolicy.java	(revision 2663)
@@ -48,7 +48,9 @@
 import java.util.Enumeration;
 import java.io.BufferedWriter;
 
+import org.apache.log4j.Logger;
 
+
 /**This class is in order to fix a problem. It doesn't has functionality for 
  *Metacat. 
  *In Currently, some document in xml_document table doesn't have entries in 
@@ -69,7 +71,8 @@
   private Vector itsDataSetIdWithouAccessEntry=null;
   private Hashtable docIdMapDataSetId=null;
   private MetaCatUtil util=null;
- 
+  private Logger logMetacat = Logger.getLogger(AssociateAccessPolicy.class);
+  
   /**
    * the main routine used to associate access policy
    */
@@ -199,7 +202,7 @@
     }//try
     catch (SQLException e)
     {
-    	MetaCatUtil.logMetacat.info("Error in getDocidListForDataPackage: "
+    	logMetacat.error("Error in getDocidListForDataPackage: "
                             +e.getMessage());
     }//catch
     //System.out.println("docid in access table");
@@ -285,7 +288,7 @@
     catch (SQLException e)
     {
       pStmt.close();
-      MetaCatUtil.logMetacat.info("Error in getDocidListForDataPackage: "
+      logMetacat.error("Error in getDocidListForDataPackage: "
                             +e.getMessage());
     }//catch
     //System.out.println("docid without access entry:");
@@ -481,7 +484,7 @@
         {
           pStmt.close();
           insertStatement.close();
-          MetaCatUtil.logMetacat.info("Error in getDocidListForDataPackadge: "
+          logMetacat.error("Error in getDocidListForDataPackadge: "
                             +e.getMessage());
         }//catch
         
Index: src/edu/ucsb/nceas/metacat/EventLog.java
===================================================================
--- src/edu/ucsb/nceas/metacat/EventLog.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/EventLog.java	(revision 2663)
@@ -29,6 +29,8 @@
 import java.sql.Timestamp;
 import java.util.Date;
 
+import org.apache.log4j.Logger;
+
 /**
  * EventLog is used to intialize and store a log of events that occur in an
  * application. The events are registered with the logger as they occur, but
@@ -57,6 +59,7 @@
      * The single instance of the event log that is always returned.
      */
     private static EventLog self = null;
+    private Logger logMetacat = Logger.getLogger(EventLog.class);
 
     /**
      * A private constructor that initializes the class when getInstance() is
@@ -128,8 +131,8 @@
             stmt.executeUpdate();
             stmt.close();
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage("Error while logging event to database: " 
-                    + e.getMessage(), 5);
+        	logMetacat.error("Error while logging event to database: " 
+                    + e.getMessage());
         } finally {
             // Return database connection to the pool
             DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -230,8 +233,8 @@
             resultDoc.append("</log>");
             stmt.close();
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage("Error while logging event to database: "
-                            + e.getMessage(), 5);
+        	logMetacat.info("Error while logging event to database: "
+                            + e.getMessage());
         } finally {
             // Return database connection to the pool
             DBConnectionPool.returnDBConnection(dbConn, serialNumber);
Index: src/edu/ucsb/nceas/metacat/MetaCatServlet.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/MetaCatServlet.java	(revision 2663)
@@ -65,6 +65,9 @@
 import com.oreilly.servlet.multipart.ParamPart;
 import com.oreilly.servlet.multipart.Part;
 
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
 import edu.ucsb.nceas.utilities.Options;
 
 /**
@@ -161,9 +164,9 @@
     private static final String CONFIG_DIR = "WEB-INF";
 
     private static final String CONFIG_NAME = "metacat.properties";
-     
-    public static String LOG_CONFIG_NAME; 
-	 
+     	 
+    private static Logger logMetacat = Logger.getLogger(MetaCatServlet.class);
+    
     /**
      * Initialize the servlet by creating appropriate database connections
      */
@@ -178,16 +181,17 @@
             String dirPath = context.getRealPath(CONFIG_DIR);
             File propertyFile = new File(dirPath, CONFIG_NAME);
 
-    	    LOG_CONFIG_NAME = dirPath + "/log4j.properties";
-	    
+            String LOG_CONFIG_NAME = dirPath + "/log4j.properties";
+            PropertyConfigurator.configureAndWatch(LOG_CONFIG_NAME);
+            
             Options options = null;
             try {
                 options = Options.initialize(propertyFile);
-                MetaCatUtil.debugMessage("Options configured: "
-                        + options.getOption("configured"), 20);
+                MetaCatUtil.printMessage("Options configured: "
+                        + options.getOption("configured"));
             } catch (IOException ioe) {
-                MetaCatUtil.debugMessage("Error in loading options: "
-                        + ioe.getMessage(), 20);
+                logMetacat.error("Error in loading options: "
+                        + ioe.getMessage());
             }
 
             util = new MetaCatUtil();
@@ -207,14 +211,14 @@
             // Index the paths specified in the metacat.properties
             checkIndexPaths();
 
-            System.out.println("Metacat (" + Version.getVersion()
+            MetaCatUtil.printMessage("Metacat (" + Version.getVersion()
                                + ") initialized.");
 
         } catch (ServletException ex) {
             throw ex;
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage("Error in MetacatServlet.init: "
-                    + e.getMessage(), 20);
+            logMetacat.error("Error in MetacatServlet.init: "
+                    + e.getMessage());
         }
     }
 
@@ -255,7 +259,7 @@
     
         if (MetaCatUtil.pathsForIndexing != null) {
     
-            MetaCatUtil.debugMessage("Indexing paths....", 20);
+            MetaCatUtil.printMessage("Indexing paths specified in metacat.properties....");
     
             DBConnection conn = null;
             int serialNumber = -1;
@@ -264,9 +268,9 @@
             ResultSet rs = null;
     
             for (int i = 0; i < MetaCatUtil.pathsForIndexing.size(); i++) {
-                MetaCatUtil.formattedDebugMessage("Checking if '"
+                logMetacat.info("Checking if '"
                            + (String) MetaCatUtil.pathsForIndexing.elementAt(i)
-                           + "' is indexed.... ",30, false, true);
+                           + "' is indexed.... ");
     
                 try {
                     //check out DBConnection
@@ -283,16 +287,15 @@
                     rs = pstmt.getResultSet();
     
                     if (!rs.next()) {
-                        MetaCatUtil.formattedDebugMessage("not indexed yet.", 30,
-                                                       true, false);
+                        logMetacat.info(".....not indexed yet.");
                         rs.close();
                         pstmt.close();
                         conn.increaseUsageCount(1);
     
-                        MetaCatUtil.debugMessage(
+                        logMetacat.debug(
                               "Inserting following path in xml_path_index: "
                               + (String)MetaCatUtil.pathsForIndexing
-                                                   .elementAt(i), 60);
+                                                   .elementAt(i));
     
                         pstmt = conn.prepareStatement("SELECT DISTINCT n.docid, "
                               + "n.nodedata, n.nodedatanumerical, n.parentnodeid"
@@ -305,10 +308,10 @@
                         rs = pstmt.getResultSet();
     
                         int count = 0;
-                        MetaCatUtil.debugMessage(
+                        logMetacat.debug(
                                        "Executed the select statement for: "
                                        + (String) MetaCatUtil.pathsForIndexing
-                                         .elementAt(i), 60);
+                                         .elementAt(i));
     
                         try {
                             while (rs.next()) {
@@ -349,14 +352,13 @@
                         pstmt.close();
                         conn.increaseUsageCount(1);
     
-                        MetaCatUtil.debugMessage("Indexed " + count
+                        logMetacat.warn("Indexed " + count
                                 + " records from xml_nodes for '"
                                 + (String) MetaCatUtil.pathsForIndexing.elementAt(i)
-                                + "'", 20);
+                                + "'");
     
                     } else {
-                        MetaCatUtil.formattedDebugMessage("already indexed.", 30,
-                                                       true, false);
+                    	logMetacat.info(".....already indexed.");
                     }
     
                     rs.close();
@@ -364,8 +366,8 @@
                     conn.increaseUsageCount(1);
     
                 } catch (Exception e) {
-                    MetaCatUtil.debugMessage("error in DocumentImpl.delete: "
-                                             + e.getMessage(), 30);
+                    logMetacat.error("Error in MetaCatServlet.checkIndexPaths: "
+                                             + e.getMessage());
                 }finally {
                     //check in DBonnection
                     DBConnectionPool.returnDBConnection(conn, serialNumber);
@@ -374,7 +376,7 @@
     
             }
     
-            MetaCatUtil.debugMessage("Path Indexing Completed", 20);
+            MetaCatUtil.printMessage("Path Indexing Completed");
         }
     }
 
@@ -390,9 +392,9 @@
             util = new MetaCatUtil();
         }
         /*
-         * MetaCatUtil.debugMessage("Connection pool size: "
+         * logMetacat.info("Connection pool size: "
          * +connPool.getSizeOfDBConnectionPool(),10);
-         * MetaCatUtil.debugMessage("Free DBConnection number: "
+         * logMetacat.info("Free DBConnection number: "
          */
         //If all DBConnection in the pool are free and DBConnection pool
         //size is greater than initial value, shrink the connection pool
@@ -448,7 +450,7 @@
             }
 
             String action = ((String[]) params.get("action"))[0];
-            MetaCatUtil.debugMessage("Line 230: Action is: " + action, 1);
+            logMetacat.warn("Action is: " + action);
 
             // This block handles session management for the servlet
             // by looking up the current session information for all actions
@@ -495,21 +497,21 @@
                 HttpSession sess = request.getSession(true);
                 if (sess.isNew() && !params.containsKey("sessionid")) {
                     // session expired or has not been stored b/w user requests
-                    MetaCatUtil.debugMessage(
-                            "in session is new or no sessionid", 40);
+                    logMetacat.warn(
+                            "The session is new or no sessionid is assigned. The user is public");
                     username = "public";
                     sess.setAttribute("username", username);
                 } else {
-                    MetaCatUtil.debugMessage("in session is not new or "
-                            + " has sessionid parameter", 40);
+                    logMetacat.warn("The session is not new or "
+                            + " has sessionid parameter");
                     try {
                         if (params.containsKey("sessionid")) {
                             sess_id = ((String[]) params.get("sessionid"))[0];
-                            MetaCatUtil.debugMessage("in has sessionid "
-                                    + sess_id, 40);
+                            logMetacat.info("in has sessionid "
+                                    + sess_id);
                             if (sessionHash.containsKey(sess_id)) {
-                                MetaCatUtil.debugMessage("find the id "
-                                        + sess_id + " in hash table", 40);
+                                logMetacat.info("find the id "
+                                        + sess_id + " in hash table");
                                 sess = (HttpSession) sessionHash.get(sess_id);
                             }
                         } else {
@@ -516,10 +518,10 @@
                             // we already store the session in login, so we
                             // don't need here
                             /*
-                             * MetaCatUtil.debugMessage("in no sessionid
+                             * logMetacat.info("in no sessionid
                              * parameter ", 40); sess_id =
                              * (String)sess.getId();
-                             * MetaCatUtil.debugMessage("storing the session id "
+                             * logMetacat.info("storing the session id "
                              * + sess_id + " which has username " +
                              * sess.getAttribute("username") + " into session
                              * hash in handleGetOrPost method", 35);
@@ -526,15 +528,15 @@
                              */
                         }
                     } catch (IllegalStateException ise) {
-                        System.out.println(
-                                "error in handleGetOrPost: this shouldn't "
+                        logMetacat.error(
+                                "Error in handleGetOrPost: this shouldn't "
                                 + "happen: the session should be valid: "
                                 + ise.getMessage());
                     }
 
                     username = (String) sess.getAttribute("username");
-                    MetaCatUtil.debugMessage("The user name from session is: "
-                            + username, 20);
+                    logMetacat.warn("The user name from session is: "
+                            + username);
                     password = (String) sess.getAttribute("password");
                     groupnames = (String[]) sess.getAttribute("groupnames");
                 }
@@ -543,7 +545,7 @@
                 if (username == null || (username.trim().equals(""))) {
                     username = "public";
                 }
-                MetaCatUtil.debugMessage("The user is : " + username, 5);
+                logMetacat.warn("The user is : " + username);
             }
             // Now that we know the session is valid, we can delegate the
             // request
@@ -737,7 +739,7 @@
         }
 
         String un = ((String[]) params.get("username"))[0];
-        MetaCatUtil.debugMessage("user " + un + " try to login", 20);
+        logMetacat.warn("user " + un + " try to login");
         String pw = ((String[]) params.get("password"))[0];
 
         String qformat = "xml";
@@ -759,9 +761,9 @@
         if (isValid) {
             HttpSession session = sess.getSessions();
             String id = session.getId();
-            MetaCatUtil.debugMessage("Store session id " + id
+            logMetacat.info("Store session id " + id
                     + "which has username" + session.getAttribute("username")
-                    + " into hash in login method", 35);
+                    + " into hash in login method");
             sessionHash.put(id, session);
         }
 
@@ -778,9 +780,9 @@
                         out, null);
             } catch (Exception e) {
 
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in MetaCatServlet.handleLoginAction: "
-                                + e.getMessage(), 30);
+                                + e.getMessage());
             }
         }
     }
@@ -799,13 +801,13 @@
 
         // close the connection
         HttpSession sess = request.getSession(false);
-        MetaCatUtil.debugMessage("After get session in logout request", 40);
+        logMetacat.info("After get session in logout request");
         if (sess != null) {
-            MetaCatUtil.debugMessage("The session id " + sess.getId()
-                    + " will be invalidate in logout action", 30);
-            MetaCatUtil.debugMessage("The session contains user "
+            logMetacat.info("The session id " + sess.getId()
+                    + " will be invalidate in logout action");
+            logMetacat.warn("The session contains user "
                     + sess.getAttribute("username")
-                    + " will be invalidate in logout action", 30);
+                    + " will be invalidate in logout action");
             sess.invalidate();
         }
 
@@ -828,9 +830,9 @@
                         "-//NCEAS//login//EN", "-//W3C//HTML//EN", qformat,
                         out, null);
             } catch (Exception e) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in MetaCatServlet.handleLogoutAction"
-                                + e.getMessage(), 30);
+                                + e.getMessage());
             }
         }
     }
@@ -855,8 +857,8 @@
         DBQuery queryobj = new DBQuery(saxparser);
         queryobj.findDocuments(response, out, params, user, groups, sessionid);
         double outPutTime = System.currentTimeMillis() / 1000;
-        MetaCatUtil.debugMessage("total search time: "
-                + (outPutTime - startTime), 30);
+        logMetacat.warn("Total search time for action 'squery': "
+                + (outPutTime - startTime));
 
     }
 
@@ -881,8 +883,8 @@
         DBQuery queryobj = new DBQuery(saxparser);
         queryobj.findDocuments(response, out, params, user, groups, sessionid);
         double outPutTime = System.currentTimeMillis() / 1000;
-        MetaCatUtil.debugMessage("total search time: "
-                + (outPutTime - startTime), 30);
+        logMetacat.warn("Total search time for action 'query': "
+                + (outPutTime - startTime));
 
         //handleSQuery(out, params, response,user, groups, sessionid);
     }
@@ -967,14 +969,14 @@
                     zOut.close();
                 }
             } catch (IOException ioe) {
-                MetaCatUtil.debugMessage("Problem with the servlet output "
+                logMetacat.error("Problem with the servlet output "
                         + "in MetacatServlet.handleExportAction: "
-                        + ioe.getMessage(), 30);
+                        + ioe.getMessage());
             }
 
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in MetacatServlet.handleExportAction: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             e.printStackTrace(System.out);
 
         }
@@ -1082,13 +1084,13 @@
                     out.close();
                 }
             } catch (IOException ioe) {
-                MetaCatUtil.debugMessage("Problem with the servlet output "
+                logMetacat.error("Problem with the servlet output "
                         + "in MetacatServlet.handleExportAction: "
-                        + ioe.getMessage(), 30);
+                        + ioe.getMessage());
             }
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in MetacatServlet.handleReadInlineDataAction: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
         }
     }
 
@@ -1138,8 +1140,8 @@
                 DBConnectionPool.returnDBConnection(conn, serialNumber);
             }
         }
-        MetaCatUtil.debugMessage("The nodeid for inlinedataid " + inLineDataId
-                + " is: " + nodeId, 35);
+        logMetacat.info("The nodeid for inlinedataid " + inLineDataId
+                + " is: " + nodeId);
         return nodeId;
     }
 
@@ -1244,8 +1246,8 @@
             // the docid which didn't be found
             String notFoundDocId = notFoundE.getUnfoundDocId();
             String notFoundRevision = notFoundE.getUnfoundRevision();
-            MetaCatUtil.debugMessage("Missed id: " + notFoundDocId, 30);
-            MetaCatUtil.debugMessage("Missed rev: " + notFoundRevision, 30);
+            logMetacat.warn("Missed id: " + notFoundDocId);
+            logMetacat.warn("Missed rev: " + notFoundRevision);
             try {
                 // read docid from remote server
                 readFromRemoteMetaCat(response, notFoundDocId,
@@ -1260,9 +1262,9 @@
                 }
 
             } catch (Exception exc) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Erorr in MetacatServlet.hanldReadAction: "
-                                + exc.getMessage(), 30);
+                                + exc.getMessage());
                 try {
                     if (out != null) {
                         response.setContentType("text/xml");
@@ -1293,9 +1295,9 @@
                         zout.close();
                     }
                 } catch (IOException ie) {
-                    MetaCatUtil.debugMessage("Problem with the servlet output "
+                    logMetacat.error("Problem with the servlet output "
                             + "in MetacatServlet.handleReadAction: "
-                            + ie.getMessage(), 30);
+                            + ie.getMessage());
                 }
             }
         } catch (Exception e) {
@@ -1329,16 +1331,16 @@
                 }
 
             } catch (IOException ioe) {
-                MetaCatUtil.debugMessage("Problem with the servlet output "
+                logMetacat.error("Problem with the servlet output "
                         + "in MetacatServlet.handleReadAction: "
-                        + ioe.getMessage(), 30);
+                        + ioe.getMessage());
                 ioe.printStackTrace(System.out);
 
             }
 
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in MetacatServlet.handleReadAction: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             //e.printStackTrace(System.out);
         }
     }
@@ -1390,8 +1392,8 @@
                     ContentTypeProvider provider = new ContentTypeProvider(
                             docid);
                     contentType = provider.getContentType();
-                    MetaCatUtil.debugMessage("Final contenttype is: "
-                            + contentType, 30);
+                    logMetacat.warn("Final contenttype is: "
+                            + contentType);
                 }
 
                 response.setContentType(contentType);
@@ -1636,7 +1638,7 @@
             out.println("<error>");
             out.println("Docid not specified");
             out.println("</error>");
-            MetaCatUtil.debugMessage("Docid not specified",10);
+            logMetacat.error("Docid not specified");
             return;
         }
         
@@ -1645,7 +1647,7 @@
             out.println("<error>");
             out.println("User '" + user + "' not allowed to insert and update");
             out.println("</error>");
-            MetaCatUtil.debugMessage("User '" + user + "' not allowed to insert and update",10);
+            logMetacat.error("User '" + user + "' not allowed to insert and update");
             return;
         }
 
@@ -1735,8 +1737,8 @@
                     // write the document to the database
                     try {
                         String accNumber = docid[0];
-                        MetaCatUtil.debugMessage("" + doAction + " "
-                                + accNumber + "...", 10);
+                        logMetacat.warn("" + doAction + " "
+                                + accNumber + "...");
                         if (accNumber.equals("")) {
                             accNumber = null;
                         }
@@ -1835,7 +1837,7 @@
             }
         }
 
-        MetaCatUtil.debugMessage("Validation for dtd is " + validate, 10);
+        logMetacat.warn("Validation for dtd is " + validate);
         return validate;
     }
 
@@ -1846,8 +1848,8 @@
     {
         boolean needSchemaValidate = false;
         if (xml == null) {
-            MetaCatUtil.debugMessage("Validation for schema is "
-                    + needSchemaValidate, 10);
+            logMetacat.warn("Validation for schema is "
+                    + needSchemaValidate);
             return needSchemaValidate;
         }
         System.out.println("before get target line");
@@ -1861,8 +1863,8 @@
             needSchemaValidate = true;
         }
 
-        MetaCatUtil.debugMessage("Validation for schema is "
-                + needSchemaValidate, 10);
+        logMetacat.warn("Validation for schema is "
+                + needSchemaValidate);
         return needSchemaValidate;
 
     }
@@ -1877,8 +1879,8 @@
         String eml2_1_0NameSpace = DocumentImpl.EML2_1_0NAMESPACE;
 
         if (xml == null) {
-            MetaCatUtil.debugMessage("Validation for schema is "
-                    + namespace, 10);
+            logMetacat.warn("Validation for schema is "
+                    + namespace);
             return namespace;
         }
         String targetLine = getSchemaLine(xml);
@@ -1905,8 +1907,8 @@
                 }
             }
             schemaLocation = targetLine.substring(start + 1, end);
-            MetaCatUtil.debugMessage("schemaLocation in xml is: "
-                    + schemaLocation, 30);
+            logMetacat.info("schemaLocation in xml is: "
+                    + schemaLocation);
             if (schemaLocation.indexOf(eml2_0_0NameSpace) != -1) {
                 namespace = eml2_0_0NameSpace;
             } else if (schemaLocation.indexOf(eml2_0_1NameSpace) != -1) {
@@ -1916,8 +1918,7 @@
             }
         }
 
-        MetaCatUtil.debugMessage("Validation for eml is " + namespace,
-                10);
+        logMetacat.warn("Validation for eml is " + namespace);
 
         return namespace;
 
@@ -1969,8 +1970,8 @@
             tmp = xml.read();
         }
         secondLine = buffer.toString();
-        MetaCatUtil
-                .debugMessage("the second line string is: " + secondLine, 25);
+        logMetacat.info("the second line string is: " + secondLine);
+        
         xml.reset();
         return secondLine;
     }
@@ -2321,8 +2322,8 @@
                     docid, event, startDate, endDate));
             out.close();
         } catch (IOException e) {
-            MetaCatUtil.debugMessage(
-                    "Could not open http response for writing: " + e.getMessage(), 5);
+            logMetacat.error(
+                    "Could not open http response for writing: " + e.getMessage());
         }
     }
 
@@ -2383,9 +2384,9 @@
             out.println("</success>");
             out.close();
         } catch (IOException e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Could not open http response for writing: "
-                    + e.getMessage(), 5);
+                    + e.getMessage());
         }
     }
 
@@ -2428,8 +2429,8 @@
         Hashtable fileList = new Hashtable();
         int sizeLimit = (new Integer(MetaCatUtil.getOption("datafilesizelimit")))
                 .intValue();
-        MetaCatUtil.debugMessage(
-                "The limit size of data file is: " + sizeLimit, 50);
+        logMetacat.info(
+                "The limit size of data file is: " + sizeLimit);
 
         try {
             // MBJ: need to put filesize limit in Metacat config
@@ -2465,8 +2466,7 @@
             try {
                 out = response.getWriter();
             } catch (IOException ioe2) {
-                System.err
-                        .println("Fatal Error: couldn't get response output stream.");
+                logMetacat.fatal("Fatal Error: couldn't get response output stream.");
             }
             out.println("<?xml version=\"1.0\"?>");
             out.println("<error>");
@@ -2504,8 +2504,8 @@
         try {
             out = response.getWriter();
         } catch (IOException ioe2) {
-            MetaCatUtil.debugMessage("Fatal Error: couldn't get response "
-                    + "output stream.", 30);
+            logMetacat.error("Fatal Error: couldn't get response "
+                    + "output stream.");
         }
 
         if (action.equals("upload")) {
@@ -2564,13 +2564,13 @@
             // Get a reference to the file part of the form
             FilePart filePart = (FilePart) fileList.get("datafile");
             String fileName = filePart.getFileName();
-            MetaCatUtil.debugMessage("Uploading filename: " + fileName, 10);
+            logMetacat.warn("Uploading filename: " + fileName);
 
             // Check if the right file existed in the uploaded data
             if (fileName != null) {
 
                 try {
-                    //MetaCatUtil.debugMessage("Upload datafile " + docid
+                    //logMetacat.info("Upload datafile " + docid
                     // +"...", 10);
                     //If document get lock data file grant
                     if (DocumentImpl.getDataFileLockGrant(docid)) {
@@ -2693,8 +2693,8 @@
         //debug
         if (packageSet != null) {
             for (int i = 0; i < packageSet.size(); i++) {
-                MetaCatUtil.debugMessage("doctype in package set: "
-                        + (String) packageSet.elementAt(i), 34);
+                logMetacat.info("doctype in package set: "
+                        + (String) packageSet.elementAt(i));
             }
         }
 
@@ -2708,8 +2708,8 @@
                 owner = getFieldValueForDoc(accessionNumber, "user_owner");
                 publicId = getFieldValueForDoc(accessionNumber, "doctype");
             } catch (Exception e) {
-                MetaCatUtil.debugMessage("Error in handleSetAccessAction: "
-                        + e.getMessage(), 30);
+                logMetacat.error("Error in handleSetAccessAction: "
+                        + e.getMessage());
                 error = "Error in set access control for document - "
                         + accessionNumber + e.getMessage();
                 errorList.addElement(error);
@@ -2751,9 +2751,9 @@
                             + accessionNumber + " successfully";
                     successList.addElement(success);
                 } catch (Exception ee) {
-                    MetaCatUtil.debugMessage(
+                    logMetacat.error(
                             "Erorr in handleSetAccessAction2: "
-                                    + ee.getMessage(), 30);
+                                    + ee.getMessage());
                     error = "Faild to set access control for document "
                             + accessionNumber + " because " + ee.getMessage();
                     errorList.addElement(error);
@@ -2804,9 +2804,9 @@
                         + accessionNumber);
             }
         } catch (Exception e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Exception in MetacatServlet.getPublicIdForDoc: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             throw e;
         } finally {
             try {
@@ -2849,9 +2849,9 @@
                 docList.add(docid + "." + rev);
             }
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Exception in MetacatServlet.getDocumentList: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             throw e;
         } finally {
             try {
@@ -2859,9 +2859,9 @@
                 pstmt.close();
 
             } catch (SQLException se) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                     "Exception in MetacatServlet.getDocumentList: "
-                            + se.getMessage(), 30);
+                            + se.getMessage());
                 throw se;
             } finally {
                 DBConnectionPool.returnDBConnection(conn, serialNumber);
@@ -2945,7 +2945,7 @@
             // in other suituation we don't change the docid
             newAccNum = docid;
         }
-        MetaCatUtil.debugMessage("The docid will be read is "+newAccNum, 20);
+        logMetacat.warn("The docid will be read is "+newAccNum);
         return newAccNum;
     }
 }
Index: src/edu/ucsb/nceas/metacat/ContentTypeProvider.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ContentTypeProvider.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/ContentTypeProvider.java	(revision 2663)
@@ -34,6 +34,7 @@
 import java.util.Hashtable;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
 import org.apache.xpath.objects.XObject;
 import org.apache.xpath.XPathAPI;
 import org.apache.xerces.parsers.DOMParser;
@@ -103,6 +104,7 @@
   private String BINARYRASTERFORMAT = "binaryRasterFormat";
 
   private String DATAFILEPATH ="//physical/distribution/online/url";
+  private static Logger logMetacat = Logger.getLogger(ContentTypeProvider.class);
 
   /**
    * Constructor of ContentTypeProvider
@@ -190,8 +192,8 @@
     {
       // if faild, set default value
       contentType = DEFAULTCONTENTTYPE;
-      MetaCatUtil.debugMessage("Error in ContentTypeProvider." +
-                         "findContentTypeInEML2()" + e.getMessage(), 30);
+      logMetacat.error("Error in ContentTypeProvider." +
+                         "findContentTypeInEML2()" + e.getMessage());
       return;
     }
     Node dataFormatNode = findDataFormatNodeInEML2(doc, DATAFILEPATH,
@@ -199,7 +201,7 @@
     if (dataFormatNode == null)
     {
       contentType = DEFAULTCONTENTTYPE;
-      MetaCatUtil.debugMessage("Couldn't find data format node", 30);
+      logMetacat.info("Couldn't find data format node");
       return;
 
     }
@@ -212,7 +214,7 @@
       // if has text format child set to text/plain
       if (child.getNodeName() != null && child.getNodeName().equals(TEXTFORMAT))
       {
-        MetaCatUtil.debugMessage("in text format", 35);
+        logMetacat.info("in text format");
         contentType = TEXTYPE;
       }
 
@@ -219,9 +221,9 @@
       //external format
       if (child.getNodeName() != null && child.getNodeName().equals(EXTENALFORMAT))
       {
-        MetaCatUtil.debugMessage("in external format ", 35);
+        logMetacat.info("in external format ");
         String format = getTextValueForGivenChildTag(child, FORMATNAME);
-        MetaCatUtil.debugMessage("The format is: "+format, 35);
+        logMetacat.info("The format is: "+format);
         // if we can find the format in the contentTypeHash table
         contentType = (String)lookUpContentType(format);
         if (contentType == null)
@@ -255,7 +257,7 @@
       Node child = childList.item(i);
       if (child.getNodeName() != null && child.getNodeName().equals(childTagName))
       {
-        MetaCatUtil.debugMessage("Find child node: " + childTagName, 35);
+        logMetacat.info("Find child node: " + childTagName);
         Node textNode = child.getFirstChild();
         if (textNode.getNodeType() == Node.TEXT_NODE)
         {
@@ -263,8 +265,8 @@
         }//if
       }//if
     }//for
-    MetaCatUtil.debugMessage("The text value for element- " + childTagName +
-                             " is " + textValue, 30);
+    logMetacat.info("The text value for element- " + childTagName +
+                             " is " + textValue);
     return textValue;
   }//getTExtValueForGivenChildTag
 
@@ -293,8 +295,8 @@
       } //for
       if (targetNode != null)
       {
-        MetaCatUtil.debugMessage("dataFormat node'name: " +
-                                 targetNode.getNodeName(), 35);
+        logMetacat.info("dataFormat node'name: " +
+                                 targetNode.getNodeName());
       }
     }//if
     return targetNode;
@@ -312,7 +314,7 @@
     catch (Exception e)
     {
       // catch an error and return null
-      MetaCatUtil.debugMessage("Error in findDataFileNode: "+e.getMessage(), 30);
+      logMetacat.error("Error in findDataFileNode: "+e.getMessage());
       return dataFileNode;
     }
     // go through the list and find target docid in online/url
@@ -325,7 +327,7 @@
         if (textNode.getNodeType() == node.TEXT_NODE)
         {
           String URLData = textNode.getNodeValue();
-          MetaCatUtil.debugMessage("online/url text data: " + URLData, 30);
+          logMetacat.info("online/url text data: " + URLData);
           //Only handle ecogrid data file
           if (URLData.indexOf(DBSAXHandler.ECOGRID) != -1 )
           {
@@ -334,13 +336,13 @@
                                getAccessionNumberFromEcogridIdentifier(URLData);
             // Get rid of revision
             docId = MetaCatUtil.getDocIdFromAccessionNumber(docId);
-            MetaCatUtil.debugMessage("docid from url element in xml is: " +
-                                     docId, 30);
+            logMetacat.info("docid from url element in xml is: " +
+                                     docId);
             //if this docid equals target one, we find it
             if (docId != null && docId.equals(targetDocId))
             {
-              MetaCatUtil.debugMessage("Find target docid in online/url: " +
-                                       docId, 30);
+              logMetacat.info("Find target docid in online/url: " +
+                                       docId);
               dataFileNode = node;
               break;
             }
@@ -395,7 +397,7 @@
                                      contains(packType))
       {
         //this is beta4 or beta6 version
-        MetaCatUtil.debugMessage("This is beta package", 30);
+        logMetacat.warn("This is beta package");
         packageType = BETA;
       }
       else if ((MetaCatUtil.getOptionList
@@ -402,7 +404,7 @@
                (MetaCatUtil.getOption("eml2_0_0namespace"))).contains(packType))
       {
         // this eml 2 document
-        MetaCatUtil.debugMessage("This is EML2.0.0 package", 30);
+        logMetacat.warn("This is EML2.0.0 package");
         packageType = EML2;
       }
       else if ((MetaCatUtil.getOptionList
@@ -409,7 +411,7 @@
                (MetaCatUtil.getOption("eml2_0_1namespace"))).contains(packType))
       {
         // this eml 2 document
-        MetaCatUtil.debugMessage("This is EML2.0.1 package", 30);
+        logMetacat.warn("This is EML2.0.1 package");
         packageType = EML2;
       }
 
@@ -419,8 +421,8 @@
     catch(SQLException e)
     {
 
-      MetaCatUtil.debugMessage("ContenTypProvider.getRelativeDoclist1 " +
-                             e.getMessage(), 30);
+      logMetacat.error("ContenTypProvider.getRelativeDoclist1 " +
+                             e.getMessage());
     }//catch
     finally
     {
@@ -430,8 +432,8 @@
       }
       catch (SQLException ee)
       {
-        MetaCatUtil.debugMessage("ContenTypProvider.getRelativeDoclist2 " +
-                             ee.getMessage(), 30);
+        logMetacat.error("ContenTypProvider.getRelativeDoclist2 " +
+                             ee.getMessage());
       }
       finally
       {
@@ -465,7 +467,7 @@
     }//for
     // add parensis
     sql = sql + ")";
-    MetaCatUtil.debugMessage("SQL for select doctype: "+ sql, 35);
+    logMetacat.info("SQL for select doctype: "+ sql);
     ResultSet rs = null;
     PreparedStatement pStmt=null;
     DBConnection conn = null;
@@ -499,8 +501,8 @@
     catch(SQLException e)
     {
 
-      MetaCatUtil.debugMessage("ContenTypProvider.setPhysicalDocIdForBeta1 " +
-                             e.getMessage(), 30);
+      logMetacat.error("ContenTypProvider.setPhysicalDocIdForBeta1 " +
+                             e.getMessage());
     }//catch
     finally
     {
@@ -510,8 +512,8 @@
       }
       catch(SQLException ee)
       {
-        MetaCatUtil.debugMessage("ContenTypProvider.setPhysicalDocIdForBeta2 " +
-                             ee.getMessage(), 30);
+        logMetacat.error("ContenTypProvider.setPhysicalDocIdForBeta2 " +
+                             ee.getMessage());
       }//catch
       finally
       {
@@ -518,8 +520,8 @@
         DBConnectionPool.returnDBConnection(conn, serialNumber);
       }
     }//finally
-    MetaCatUtil.debugMessage("target docid is: "+ docId + " "+
-                             "for target doctype: "+targetType, 25);
+    logMetacat.warn("target docid is: "+ docId + " "+
+                             "for target doctype: "+targetType);
     return docId;
   }
 
@@ -542,8 +544,8 @@
     catch (Exception e)
     {
       contentType = DEFAULTCONTENTTYPE;
-      MetaCatUtil.debugMessage("Error in ContentTypeProvider." +
-                         "parsePhysicalDocumentForBeta()" + e.getMessage(), 30);
+      logMetacat.error("Error in ContentTypeProvider." +
+                         "parsePhysicalDocumentForBeta()" + e.getMessage());
       return;
     }
       // get format element's text value
@@ -584,11 +586,11 @@
     }
     catch (Exception e)
     {
-      MetaCatUtil.debugMessage("error in ContentTypeProvider."+
-                               "getTextValueFromPath: "+e.getMessage(), 30);
+      logMetacat.error("error in ContentTypeProvider."+
+                               "getTextValueFromPath: "+e.getMessage());
     }
-    MetaCatUtil.debugMessage("The text value for " + xPath + " is: "+
-                              textValue, 30);
+    logMetacat.info("The text value for " + xPath + " is: "+
+                              textValue);
     return textValue;
   }//getTextValueFromPath
 
@@ -600,8 +602,8 @@
     newFormat = format.toLowerCase().trim();
     String type = null;
     type = (String)contentTypeHash.get(newFormat);
-    MetaCatUtil.debugMessage("contentType looked from hashtalbe is: " +
-                              type, 30);
+    logMetacat.info("contentType looked from hashtalbe is: " +
+                              type);
     return type;
   }// lookupcontentypes
 
@@ -630,12 +632,12 @@
        //ContentTypeProvider provider = new ContentTypeProvider("tao.9830");
        ContentTypeProvider provider = new ContentTypeProvider("tao.0001");
        String str = provider.getContentType();
-       MetaCatUtil.debugMessage("content type is : " + str, 20);
+       logMetacat.warn("content type is : " + str);
      }
      catch(Exception e)
      {
-       MetaCatUtil.debugMessage("erorr in Schemalocation.main: " +
-                                e.getMessage(), 30);
+       logMetacat.error("erorr in Schemalocation.main: " +
+                                e.getMessage());
      }
   }
 }//ContentTypeProvider
Index: src/edu/ucsb/nceas/metacat/AccessRule.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AccessRule.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AccessRule.java	(revision 2663)
@@ -29,7 +29,7 @@
 package edu.ucsb.nceas.metacat;
 
 import java.util.Vector;
-
+import org.apache.log4j.Logger;
 /**
  * A Class that represents an XML access rule. It include principal and 
  * permission
@@ -39,6 +39,7 @@
   private String permissionType = null;
   private Vector principal = new Vector();
   private int permission = 0;
+  private Logger logMetacat = Logger.getLogger(AccessRule.class);
   
   /** Set the permssionType */
   public void setPermissionType(String type)
@@ -87,11 +88,11 @@
     // create a new object
     AccessRule newRule = new AccessRule();
     // set permissiontype
-    MetaCatUtil.logMetacat.info("copy permission type: "+
+    logMetacat.info("copy permission type: "+
                               this.getPermissionType());
     newRule.setPermissionType(this.getPermissionType());
     // set permission
-    MetaCatUtil.logMetacat.info("copy permission: "+
+    logMetacat.info("copy permission: "+
                               this.getPermission());
     newRule.setPermission(this.getPermission());
     // walk through all the principals
@@ -99,7 +100,7 @@
     for (int i=0; i<principalVector.size(); i++)
     {
       String name = (String)principalVector.elementAt(i);
-      MetaCatUtil.logMetacat.info("copy principle: "+ name);
+      logMetacat.info("copy principle: "+ name);
       // Add this name to newrules
       newRule.addPrincipal(name);
     }
Index: src/edu/ucsb/nceas/metacat/PermissionController.java
===================================================================
--- src/edu/ucsb/nceas/metacat/PermissionController.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/PermissionController.java	(revision 2663)
@@ -35,6 +35,8 @@
 import java.util.Vector;
 import java.util.Iterator;
 
+import org.apache.log4j.Logger;
+
 public class PermissionController
 {
    private String docId = null;
@@ -45,6 +47,7 @@
    private long TOPLEVELSTARTNODEID = 0; //if start node is 0, means it is top
                                          //level document
 
+   private static Logger logMetacat = Logger.getLogger(PermissionController.class);
 
    /**
     * Constructor for PermissionController
@@ -190,8 +193,8 @@
     }//try
     catch (Exception e)
     {
-      MetaCatUtil.debugMessage("There is a exception in hasPermission method: "
-                         +e.getMessage(), 50);
+      logMetacat.warn("There is a exception in hasPermission method: "
+                         +e.getMessage());
     }
 
     return false;
@@ -346,8 +349,8 @@
         }//try
         catch( Exception e)
         {
-          MetaCatUtil.debugMessage("error in PermissionControl.has" +
-                                   "UnaccessableSubTree "+e.getMessage(), 30);
+          logMetacat.error("error in PermissionControl.has" +
+                                   "UnaccessableSubTree "+e.getMessage());
           throw new McdbException(e);
         }
 
@@ -397,10 +400,10 @@
           if (startId > subTreeStartId && endId < subTreeEndId)
           {
             needDelete = true;
-            MetaCatUtil.debugMessage("the subtree: "+ treeId +
+            logMetacat.info("the subtree: "+ treeId +
                                      " need to be get rid of from unaccessable"+
                                      " subtree list becuase it is a subtree of"+
-                                     " another subtree in the list", 45);
+                                     " another subtree in the list");
             break;
           }//if
         }//while
@@ -510,8 +513,8 @@
         // Bind the values to the query
         pStmt.setString(1, docId);
         pStmt.setString(2, principals[i]);
-        MetaCatUtil.debugMessage("the principle stack is : " +
-                                  principals[i], 40);
+        logMetacat.info("the principle stack is : " +
+                                  principals[i]);
 
         pStmt.execute();
         ResultSet rs = pStmt.getResultSet();
@@ -519,7 +522,7 @@
         if (hasRow)
         {
           pStmt.close();
-           MetaCatUtil.debugMessage("find the owner", 40);
+           logMetacat.info("find the owner");
           return true;
         }//if
 
@@ -863,15 +866,15 @@
         if (user != null)
         {
           usersPackage[0]= user.toLowerCase();
-          MetaCatUtil.debugMessage("after transfer to lower case(not null): "+
-                                     usersPackage[0], 45);
+          logMetacat.info("after transfer to lower case(not null): "+
+                                     usersPackage[0]);
         }
         else
         {
           usersPackage[0] = user;
           usersPackage[0]= user.toLowerCase();
-          MetaCatUtil.debugMessage("after transfer to lower case(null): "+
-                                     usersPackage[0], 45);
+          logMetacat.info("after transfer to lower case(null): "+
+                                     usersPackage[0]);
         }
         usersPackage[1]=AccessControlInterface.PUBLIC;
         //put groups element from index 0 to lengthOfPackage-3 into userPackage
@@ -1005,21 +1008,21 @@
         {
             if(withRevision)
             {
-                MetaCatUtil.debugMessage("Put subtree id " + subTreeId +
+                logMetacat.info("Put subtree id " + subTreeId +
                                          " and " + "inline data file name " +
                                          fileId + " into " + "un" + permission +
-                                         " hash", 20);
+                                         " hash");
                 unAccessbleIdList.put(subTreeId, fileId);
 
             }
             else
             {
-                MetaCatUtil.debugMessage("Put subtree id " + subTreeId +
+                logMetacat.info("Put subtree id " + subTreeId +
                                          " and " + "inline data file name " +
                                          MetaCatUtil.
                                          getInlineDataIdWithoutRev(fileId) +
                                          " into " + "un" + permission +
-                                         " hash", 20);
+                                         " hash");
                 unAccessbleIdList.put(subTreeId, MetaCatUtil.
                                       getInlineDataIdWithoutRev(fileId));
             }
Index: src/edu/ucsb/nceas/metacat/DocumentImpl.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DocumentImpl.java	(revision 2663)
@@ -52,6 +52,7 @@
 
 import edu.ucsb.nceas.dbadapter.AbstractDatabase;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.DTDHandler;
 import org.xml.sax.EntityResolver;
@@ -124,6 +125,8 @@
     private ElementNode rootNode = null;
     private TreeSet nodeRecordList = null;
     
+    private static Logger logMetacat = Logger.getLogger(DocumentImpl.class);
+
     /**
      * Default constructor
      *
@@ -543,10 +546,10 @@
      private static String checkRevInXMLDocuments(String docid, int userSpecifyRev) throws Exception
      {
         String action = null;
-        MetaCatUtil.debugMessage("The user specifyRev: " + userSpecifyRev, 30);
+        logMetacat.info("The user specifyRev: " + userSpecifyRev);
         // Revision for this docid in current database
         int revInDataBase =DBUtil.getLatestRevisionInDocumentTable(docid);
-        MetaCatUtil.debugMessage("The rev in data base: " + revInDataBase, 30);
+        logMetacat.info("The rev in data base: " + revInDataBase);
         // String to store the revision
         String rev = null;
 
@@ -598,14 +601,14 @@
          }
          catch (SQLException e)
          {
-           MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+
-                                  " be found because " + e.getMessage(), 45);
+           logMetacat.error("Local rev for docid "+ docid + " could not "+
+                                  " be found because " + e.getMessage());
            MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+
                    "written because error happend to find it's local revision");
            throw new Exception (e.getMessage());
          }
-         MetaCatUtil.debugMessage("rev list in xml_revision table for docid "+ docid + " is "+
-                                 localrev.toString(), 45);
+         logMetacat.info("rev list in xml_revision table for docid "+ docid + " is "+
+                                 localrev.toString());
          
          // if the rev is in the xml_revision, it throws a exception
          if (localrev.contains(new Integer(rev)))
@@ -942,10 +945,10 @@
         while (it.hasNext()) {
 
             NodeRecord currentNode = (NodeRecord) it.next();
-            util.debugMessage("[Got Node ID: " + currentNode.nodeid + " ("
+            logMetacat.info("[Got Node ID: " + currentNode.nodeid + " ("
                     + currentNode.parentnodeid + ", " + currentNode.nodeindex
                     + ", " + currentNode.nodetype + ", " + currentNode.nodename
-                    + ", " + currentNode.nodedata + ")]", 50);
+                    + ", " + currentNode.nodedata + ")]");
             // Print the end tag for the previous node if needed
             //
             // This is determined by inspecting the parent nodeid for the
@@ -967,8 +970,8 @@
                 if (currentNode.parentnodeid != currentElement.nodeid) {
                     while (currentNode.parentnodeid != currentElement.nodeid) {
                         currentElement = (NodeRecord) openElements.pop();
-                        util.debugMessage("\n POPPED: "
-                                + currentElement.nodename, 50);
+                        logMetacat.info("\n POPPED: "
+                                + currentElement.nodename);
                         if (previousNodeWasElement) {
                             out.print(">");
                             previousNodeWasElement = false;
@@ -1015,7 +1018,7 @@
                 }
                 firstElement = false;
                 openElements.push(currentNode);
-                util.debugMessage("\n PUSHED: " + currentNode.nodename, 50);
+                logMetacat.info("\n PUSHED: " + currentNode.nodename);
                 previousNodeWasElement = true;
                 if (currentNode.nodeprefix != null) {
                     out.print("<" + currentNode.nodeprefix + ":"
@@ -1169,7 +1172,7 @@
         // Print the final end tag for the root element
         while (!openElements.empty()) {
             NodeRecord currentElement = (NodeRecord) openElements.pop();
-            util.debugMessage("\n POPPED: " + currentElement.nodename, 50);
+            logMetacat.info("\n POPPED: " + currentElement.nodename);
             if (currentElement.nodeprefix != null) {
                 out.print("</" + currentElement.nodeprefix + ":"
                         + currentElement.nodename + ">");
@@ -1212,11 +1215,11 @@
         /*try {
             doc = new DocumentIdentifier(docid);
         } catch (AccessionNumberException e){
-            MetaCatUtil.debugMessage("AccessionNumber Exception while "
+            logMetacat.info("AccessionNumber Exception while "
                                      + " inserting path index "
                                      + "in DocumentImpl.buildIndex for "
                                      + "document " + docid, 10);
-            MetaCatUtil.debugMessage(e.getMessage(), 10);
+            logMetacat.info(e.getMessage(), 10);
         }*/
 
         // Opening separate db connection for deleting and writing
@@ -1273,17 +1276,17 @@
 
             dbConn.commit();
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage("SQL Exception while inserting path index "
+            logMetacat.error("SQL Exception while inserting path index "
                                      + "in DocumentImpl.buildIndex for "
-                                     + "document " + docid, 10);
-            MetaCatUtil.debugMessage(e.getMessage(), 10);
+                                     + "document " + docid);
+            logMetacat.error(e.getMessage());
             try {
                 dbConn.rollback();
             } catch (SQLException sqle) {
-                MetaCatUtil.debugMessage("Error while rolling back "
+                logMetacat.error("Error while rolling back "
                                          + "commit in DocumentImpl"
                                          + ".buildIndex" + "\n"
-                                         + sqle.getMessage(), 10);
+                                         + sqle.getMessage());
             }
         } finally {
             DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1351,23 +1354,22 @@
             pstmt.close();
             dbConn.increaseUsageCount(1);
 
-            MetaCatUtil.debugMessage("Indexed " + count
-                                              + " records from xml_nodes",
-                                              20);
+            logMetacat.warn("Indexed " + count
+                                              + " records from xml_nodes");
 
             dbConn.commit();
         } catch (SQLException e) {
-          MetaCatUtil.debugMessage("SQL Exception while inserting path index "
+          logMetacat.error("SQL Exception while inserting path index "
                                    + "in DocumentImpl.buildIndex for "
-                                   + "document " + docid, 10);
-          MetaCatUtil.debugMessage(e.getMessage(), 10);
+                                   + "document " + docid);
+          logMetacat.error(e.getMessage());
           try {
               dbConn.rollback();
           } catch (SQLException sqle) {
-              MetaCatUtil.debugMessage("Error while rolling back "
+              logMetacat.error("Error while rolling back "
                                        + "commit in DocumentImpl"
                                        + ".buildIndex" + "\n"
-                                       + sqle.getMessage(), 10);
+                                       + sqle.getMessage());
           }
       } finally {
           DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1400,7 +1402,7 @@
                 if (current.nodetype.equals("ATTRIBUTE")) {
                     currentName = "@" + currentName;
                 }
-                MetaCatUtil.debugMessage("A: " + currentName +"\n", 60);
+                logMetacat.debug("A: " + currentName +"\n");
                 pathList.put(currentName, new PathIndexEntry(leafNodeId,
                     currentName, docid, doctype, parentId));
             }
@@ -1412,13 +1414,13 @@
             }
             String path = current.getNodeName() + children;
             if (!children.equals("")) {
-                MetaCatUtil.debugMessage("B: " + path +"\n", 60);
+                logMetacat.debug("B: " + path +"\n");
                 pathList.put(path, new PathIndexEntry(leafNodeId, path, docid,
                     doctype, parentId));
             }
             if (id == rootNodeId) {
                 String fullPath = '/' + path;
-                MetaCatUtil.debugMessage("C: " + fullPath +"\n", 60);
+                logMetacat.debug("C: " + fullPath +"\n");
                 pathList.put(fullPath, new PathIndexEntry(leafNodeId, fullPath,
                     docid, doctype, parentId));
             }
@@ -1437,8 +1439,8 @@
         //String familyId = MetaCatUtil.getDocIdFromString(docid);
         String familyId = docid;
         String sql = "DELETE FROM xml_index WHERE docid LIKE ?";
-        MetaCatUtil.debugMessage(sql, 55);
-        MetaCatUtil.debugMessage("SQL is: " + sql, 60);
+        logMetacat.debug(sql);
+        logMetacat.debug("SQL is: " + sql);
 
         PreparedStatement pstmt = conn.prepareStatement(sql);
 
@@ -1449,8 +1451,8 @@
         pstmt.setString(1, familyId);
         int rows = pstmt.executeUpdate();
         pstmt.close();
-        MetaCatUtil.debugMessage("Deleted " + rows + " rows from xml_index " +
-            "for document " + docid, 55);
+        logMetacat.debug("Deleted " + rows + " rows from xml_index " +
+            "for document " + docid);
     }
 
     /**
@@ -1479,8 +1481,8 @@
         Iterator it = pathList.values().iterator();
         while (it.hasNext()) {
             PathIndexEntry entry = (PathIndexEntry)it.next();
-            MetaCatUtil.debugMessage("Inserting: " + entry.nodeId +
-                " (" + entry.parentId + "): " + entry.path, 60);
+            logMetacat.debug("Inserting: " + entry.nodeId +
+                " (" + entry.parentId + "): " + entry.path);
             pstmt.setLong(1, entry.nodeId);
             pstmt.setString(2, entry.path);
             pstmt.setLong(5, entry.parentId);
@@ -1590,8 +1592,8 @@
             throw notFound;
         } catch (Exception e) {
 
-            MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
-                    + e.getMessage(), 30);
+            logMetacat.error("error in DocumentImpl.getDocumentInfo: "
+                    + e.getMessage());
             throw e;
         }
 
@@ -1645,7 +1647,7 @@
                     this.docHomeServer = MetaCatUtil
                             .getLocalReplicationServerName();
                 }
-                MetaCatUtil.debugMessage("server: " + docHomeServer, 50);
+                logMetacat.info("server: " + docHomeServer);
 
             }
             pstmt.close();
@@ -1668,8 +1670,8 @@
                 pstmt.close();
             }
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
-                    + e.getMessage(), 30);
+            logMetacat.error("error in DocumentImpl.getDocumentInfo: "
+                    + e.getMessage());
             e.printStackTrace(System.out);
             throw new McdbException("Error accessing database connection in "
                     + "DocumentImpl.getDocumentInfo: ", e);
@@ -1677,9 +1679,9 @@
             try {
                 pstmt.close();
             } catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "error in DocumentImple.getDocumentInfo: "
-                                + ee.getMessage(), 30);
+                                + ee.getMessage());
             } finally {
                 DBConnectionPool.returnDBConnection(dbconn, serialNumber);
             }
@@ -1729,8 +1731,8 @@
                     + ")";
 
         }
-        MetaCatUtil.debugMessage("The final query to select part node tree: "
-                + sql, 25);
+        logMetacat.info("The final query to select part node tree: "
+                + sql);
 
         try {
             dbconn = DBConnectionPool
@@ -1770,9 +1772,9 @@
             try {
                 pstmt.close();
             } catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "error in DocumentImpl.getPartNodeRecordList: "
-                                + ee.getMessage(), 30);
+                                + ee.getMessage());
             } finally {
                 DBConnectionPool.returnDBConnection(dbconn, serialNumber);
             }
@@ -1819,8 +1821,8 @@
             throw notFound;
         } catch (Exception e) {
 
-            MetaCatUtil.debugMessage("error in DocumentImpl.getDocumentInfo: "
-                    + e.getMessage(), 30);
+            logMetacat.error("error in DocumentImpl.getDocumentInfo: "
+                    + e.getMessage());
         }
         //System.out.println("in getNodeREcorelist !!!!!!!!!!!3");
         try {
@@ -1867,9 +1869,9 @@
             try {
                 pstmt.close();
             } catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "error in DocumentImpl.getNodeRecordList: "
-                                + ee.getMessage(), 30);
+                                + ee.getMessage());
             } finally {
                 DBConnectionPool.returnDBConnection(dbconn, serialNumber);
             }
@@ -1946,12 +1948,12 @@
                 
             } else if (action.equals("UPDATE")) {
                 int thisrev = DBUtil.getLatestRevisionInDocumentTable(docid);
-                MetaCatUtil.debugMessage("this revsion is: " + thisrev, 40);
+                logMetacat.info("this revsion is: " + thisrev);
                 // Save the old document publicaccessentry in a backup table
                 String accNumber = docid+MetaCatUtil.getOption("accNumSeparator")+thisrev;
                 thisdoc = new DocumentImpl(accNumber, false);
                 DocumentImpl.archiveDocAndNodesRevision(connection, docid, user, thisdoc);
-                MetaCatUtil.debugMessage("after archiveDoc", 30);
+                logMetacat.info("after archiveDoc");
                 //if the updated vesion is not greater than current one,
                 //throw it into a exception
                 if (rev <= thisrev) {
@@ -1961,17 +1963,17 @@
                     //set the user specified revision
                     thisrev = rev;
                 }
-                MetaCatUtil.debugMessage("final revsion is: " + thisrev, 40);
+                logMetacat.info("final revsion is: " + thisrev);
                 boolean useXMLIndex = (new Boolean(MetaCatUtil
                         .getOption("usexmlindex"))).booleanValue();
                 if (useXMLIndex) {
-                    MetaCatUtil.debugMessage("before delete", 40);
+                    logMetacat.info("before delete");
                     // Delete index for the old version of docid
                     // The new index is inserting on the next calls to DBSAXNode
                     pstmt = connection
                             .prepareStatement("DELETE FROM xml_index WHERE docid='"
                                     + this.docid + "'");
-                    MetaCatUtil.debugMessage("after delete", 40);
+                    logMetacat.info("after delete");
                     // Increase dbconnection usage count
                     connection.increaseUsageCount(1);
                   
@@ -2121,13 +2123,13 @@
     {
         // NEW - WHEN CLIENT ALWAYS PROVIDE ACCESSION NUMBER INCLUDING REV IN IT
         //MetaCatUtil util = new MetaCatUtil();
-        MetaCatUtil.debugMessage("conn usage count before writting: "
-                + conn.getUsageCount(), 50);
+        logMetacat.info("conn usage count before writting: "
+                + conn.getUsageCount());
         AccessionNumber ac = new AccessionNumber(accnum, action);
         String docid = ac.getDocid();
         String rev = ac.getRev();
-        MetaCatUtil.debugMessage("action: " + action + " servercode: "
-                + serverCode + " override: " + override, 10);
+        logMetacat.warn("action: " + action + " servercode: "
+                + serverCode + " override: " + override);
 
         if ((serverCode != 1 && action.equals("UPDATE")) && !override) {
             // if this document being written is not a resident of this server
@@ -2292,10 +2294,10 @@
               pstmt.close();
               conn.increaseUsageCount(1);
           } catch (Exception e){
-              MetaCatUtil.debugMessage("Error in deleting enteries from "
+              logMetacat.error("Error in deleting enteries from "
                                        + "xml_queryresult where docid is "
                                        + docid + " in DBQuery.write: "
-                                       + e.getMessage(), 20);
+                                       + e.getMessage());
            }
 
         }
@@ -2307,8 +2309,8 @@
         ForceReplicationHandler frh = new ForceReplicationHandler(accnum,
                 action, true, null);
 
-        MetaCatUtil.debugMessage("Conn Usage count after writting: "
-                + conn.getUsageCount(), 50);
+        logMetacat.info("Conn Usage count after writting: "
+                + conn.getUsageCount());
         return (accnum);
     }
 
@@ -2349,15 +2351,15 @@
         String docType = null;
         String docName = null;
         String catalogId = null;
-        MetaCatUtil.debugMessage("user in replication" + user, 30);
+        logMetacat.info("user in replication" + user);
         // Docid without revision
         String docid = MetaCatUtil.getDocIdFromAccessionNumber(accnum);
         // Revision specified by user (int)
         int userSpecifyRev = MetaCatUtil.getRevisionFromAccessionNumber(accnum);
-        MetaCatUtil.debugMessage("The user specifyRev: " + userSpecifyRev, 30);
+        logMetacat.info("The user specifyRev: " + userSpecifyRev);
         // Revision for this docid in current database
         int revInDataBase = DBUtil.getLatestRevisionInDocumentTable(docid);
-        MetaCatUtil.debugMessage("The rev in data base: " + revInDataBase, 30);
+        logMetacat.info("The rev in data base: " + revInDataBase);
         // String to store the revision
         String rev = (new Integer(userSpecifyRev)).toString();
 
@@ -2383,10 +2385,9 @@
         // Get server code again
         serverCode = getServerCode(homeServer);
 
-        MetaCatUtil
-                .debugMessage("Document " + docid + "." + rev + " " + action
+        logMetacat.warn("Document " + docid + "." + rev + " " + action
                         + " into local" + " metacat with servercode: "
-                        + serverCode, 10);
+                        + serverCode);
 
         // insert into xml_nodes table
         XMLReader parser = null;
@@ -2465,9 +2466,9 @@
             MetacatReplication.replErrorLog("Failed to " + "create access "
                     + "rule for package: " + accnum + " because "
                     + ee.getMessage());
-            MetaCatUtil.debugMessage("Failed to  " + "create access "
+            logMetacat.error("Failed to  " + "create access "
                     + "rule for package: " + accnum + " because "
-                    + ee.getMessage(), 30);
+                    + ee.getMessage());
         }
         //Force replication to other server
         if (!timedReplication)
@@ -2536,9 +2537,9 @@
                 dbconn.rollback();
                 dbconn.setAutoCommit(true);
             }
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in DocumentImple.runRelationAndAccessHandler "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             throw e;
         } finally {
             if (dbconn != null) {
@@ -2589,9 +2590,8 @@
             pstate.close();
         }//try
         catch (SQLException e) {
-            MetaCatUtil.debugMessage("error in DocumentImpl."
-                    + "getDocTypeFromDBForCurrentDocument " + e.getMessage(),
-                    30);
+            logMetacat.error("error in DocumentImpl."
+                    + "getDocTypeFromDBForCurrentDocument " + e.getMessage());
             throw e;
         }//catch
         finally {
@@ -2598,8 +2598,8 @@
             pstate.close();
             DBConnectionPool.returnDBConnection(dbConnection, serialNumber);
         }//
-        MetaCatUtil.debugMessage("The current doctype from db is: "
-                + docoumentType, 35);
+        logMetacat.info("The current doctype from db is: "
+                + docoumentType);
         return docoumentType;
     }
 
@@ -2654,7 +2654,7 @@
               isXML = false;
             }
 
-            MetaCatUtil.debugMessage("Start deleting doc " + docid + "...", 20);
+            logMetacat.warn("Start deleting doc " + docid + "...");
             // check for 'write' permission for 'user' to delete this document
             if (!hasAllPermission(user, groups, accnum)) {
                 if(!MetaCatUtil.isAdministrator(user, groups)){
@@ -2760,9 +2760,8 @@
             conn.setAutoCommit(true);
 
         } catch (Exception e) {
-            MetaCatUtil.debugMessage("error in DocumentImpl.delete: "
-                    + e.getMessage(), 30);
-    e.printStackTrace();
+            logMetacat.error("error in DocumentImpl.delete: "
+                    + e.getMessage());
             throw e;
         } finally {
 
@@ -2796,8 +2795,8 @@
       {
         type = result.getString(1);
       }
-      MetaCatUtil.debugMessage("The type of deleting docid " + docidWithoutRev +
-                               " is " + type, 2);
+      logMetacat.warn("The type of deleting docid " + docidWithoutRev +
+                               " is " + type);
       return type;
     }
 
@@ -2862,7 +2861,7 @@
             String parserName = MetaCatUtil.getOption("saxparser");
             parser = XMLReaderFactory.createXMLReader(parserName);
             if (ruleBase != null && ruleBase.equals(EML200)) {
-                MetaCatUtil.debugMessage("eml 2.0.0 parser", 20);
+                logMetacat.warn("eml 2.0.0 parser");
                 chandler = new Eml200SAXHandler(dbconn, action, docid, rev,
                         user, groups, pub, serverCode, createDate, updateDate);
                 chandler.setIsRevisionDoc(isRevision);
@@ -2887,7 +2886,7 @@
                             externalSchemaLocation);
                 }
             } else if (ruleBase != null && ruleBase.equals(EML210)) {
-                MetaCatUtil.debugMessage("eml 2.1.0 parser", 20);
+                logMetacat.warn("eml 2.1.0 parser");
                 chandler = new Eml210SAXHandler(dbconn, action, docid, rev,
                         user, groups, pub, serverCode, createDate, updateDate);
                 chandler.setIsRevisionDoc(isRevision);
@@ -2924,7 +2923,7 @@
 
                 if (ruleBase != null && ruleBase.equals(SCHEMA)
                         && needValidation) {
-                    MetaCatUtil.debugMessage("General schema parser", 20);
+                    logMetacat.warn("General schema parser");
                     // turn on schema validation feature
                     parser.setFeature(VALIDATIONFEATURE, true);
                     parser.setFeature(NAMESPACEFEATURE, true);
@@ -2945,7 +2944,7 @@
 
                 } else if (ruleBase != null && ruleBase.equals(DTD)
                         && needValidation) {
-                    MetaCatUtil.debugMessage("dtd parser", 20);
+                    logMetacat.warn("dtd parser");
                     // turn on dtd validaton feature
                     parser.setFeature(VALIDATIONFEATURE, true);
                     eresolver = new DBEntityResolver(dbconn,
@@ -2954,7 +2953,7 @@
                     parser.setEntityResolver((EntityResolver) eresolver);
                     parser.setDTDHandler((DTDHandler) dtdhandler);
                 } else {
-                    MetaCatUtil.debugMessage("other parser", 20);
+                    logMetacat.warn("other parser");
                     // non validation
                     parser.setFeature(VALIDATIONFEATURE, false);
                     eresolver = new DBEntityResolver(dbconn,
@@ -2995,9 +2994,9 @@
             archiveDocAndNodesRevison(dbconn, docid, user, rootNodeId);
 
         }catch (Exception e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in DocumentImpl.archiveDocRevision : "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
         }
        
         
@@ -3043,14 +3042,14 @@
         pstmt.close();
 
       } catch (SQLException e) {
-        MetaCatUtil.debugMessage(
+        logMetacat.error(
                 "Error in DocumentImpl.archiveDocAndNodesRevision : "
-                        + e.getMessage(), 30);
+                        + e.getMessage());
         throw e;
       } catch (Exception e) {
-        MetaCatUtil.debugMessage(
+        logMetacat.error(
                 "Error in DocumentImpl.archiveDocAndNodesRevision : "
-                        + e.getMessage(), 30);
+                        + e.getMessage());
         throw e;
       }
       finally {
@@ -3057,9 +3056,9 @@
         try {
             pstmt.close();
         } catch (SQLException ee) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in DocumnetImpl.archiveDocRevision: "
-                            + ee.getMessage(), 50);
+                            + ee.getMessage());
         }
       }
        
@@ -3068,8 +3067,8 @@
     private static void moveNodesToNodesRevision(DBConnection dbconn,
                                        long rootNodeId) throws Exception
     {
-        MetaCatUtil.debugMessage("the root node id is "+rootNodeId+
-                " will be moved from xml_nodes to xml_node_revision table", 20);
+        logMetacat.warn("the root node id is "+rootNodeId+
+                " will be moved from xml_nodes to xml_node_revision table");
         PreparedStatement pstmt = null;
         // Move the nodes from xml_nodes to xml_revisions table...
         pstmt = dbconn.prepareStatement("INSERT INTO xml_nodes_revisions "
@@ -3120,17 +3119,17 @@
             pstmt.execute();
             pstmt.close();
         } catch (SQLException e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in DocumentImpl.archiveDocRevision : "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             throw e;
         } finally {
             try {
                 pstmt.close();
             } catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DocumnetImpl.archiveDocRevision: "
-                                + ee.getMessage(), 50);
+                                + ee.getMessage());
                 throw ee;
             } finally {
                 //check in DBConnection
@@ -3163,9 +3162,9 @@
             try {
                 pStmt.close();
             } catch (SQLException e) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "error in DocumentImpl.deleteXMLDocuments: "
-                                + e.getMessage(), 50);
+                                + e.getMessage());
             } finally {
                 //return back DBconnection
                 DBConnectionPool.returnDBConnection(conn, serialNumber);
@@ -3221,9 +3220,9 @@
                 pStmt.close();
             }//try
             catch (Exception ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DocumentImpl.getServerLocationNu(): "
-                                + ee.getMessage(), 50);
+                                + ee.getMessage());
             }//catch
             finally {
                 DBConnectionPool.returnDBConnection(conn, serialNumber);
@@ -3277,15 +3276,15 @@
                 pStmt.close();
             }
         } catch (Exception e) {
-            MetaCatUtil.debugMessage("Error in DocumentImpl.getServerCode(): "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in DocumentImpl.getServerCode(): "
+                    + e.getMessage());
         } finally {
             try {
                 pStmt.close();
             } catch (Exception ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DocumentImpl.getServerCode(): "
-                                + ee.getMessage(), 50);
+                                + ee.getMessage());
             } finally {
                 DBConnectionPool.returnDBConnection(dbConn, serialNumber);
             }
@@ -3360,9 +3359,9 @@
             }
         }//try
         catch (Exception e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in DocumentImpl.insertServerIntoRepli(): "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
         }//catch
         finally {
 
@@ -3373,9 +3372,9 @@
 
             }//try
             catch (Exception ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DocumentImpl.insetServerIntoRepl(): "
-                                + ee.getMessage(), 50);
+                                + ee.getMessage());
             }//catch
             finally {
                 DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -3481,7 +3480,7 @@
             if (action.equals("READ")) {
                 DocumentImpl xmldoc = new DocumentImpl(docid);
                 if (useOldReadAlgorithm) {
-                    MetaCatUtil.debugMessage(xmldoc.readUsingSlowAlgorithm(), 10);
+                    logMetacat.error(xmldoc.readUsingSlowAlgorithm());
                 } else {
                     xmldoc.toXml(new PrintWriter(System.out), null, null, true);
                 }
@@ -3508,12 +3507,12 @@
             double insertTime = (stopTime - connTime) / 1000;
             double executionTime = (stopTime - startTime) / 1000;
             if (showRuntime) {
-                MetaCatUtil.debugMessage("\n\nTotal Execution time was: "
-                        + executionTime + " seconds.", 10);
-                MetaCatUtil.debugMessage("Time to open DB connection was: "
-                        + dbOpenTime + " seconds.", 10);
-                MetaCatUtil.debugMessage("Time to insert document was: " + insertTime
-                        + " seconds.", 10);
+                logMetacat.warn("\n\nTotal Execution time was: "
+                        + executionTime + " seconds.");
+                logMetacat.warn("Time to open DB connection was: "
+                        + dbOpenTime + " seconds.");
+                logMetacat.warn("Time to insert document was: " + insertTime
+                        + " seconds.");
             }
             dbconn.close();
         } catch (McdbException me) {
@@ -3550,7 +3549,7 @@
             {
                 createDate = dbAdapter.toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
             }
-            MetaCatUtil.debugMessage("the create date is "+createDate, 30);
+            logMetacat.info("the create date is "+createDate);
             if (updateDate == null)
             {
                 updateDate = dbAdapter.getDateTimeFunction();
@@ -3559,10 +3558,10 @@
             {
                 updateDate = dbAdapter.toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
             }
-            MetaCatUtil.debugMessage("the update date is "+updateDate, 30);
+            logMetacat.info("the update date is "+updateDate);
             PreparedStatement pstmt = null;
             String sql = null;
-            MetaCatUtil.debugMessage("the root node id is "+rootNodeId, 20);
+            logMetacat.info("the root node id is "+rootNodeId);
             if (rootNodeId <= 0)
             {
             	// this is for data file, not rootnodeid need
@@ -3588,32 +3587,32 @@
 
             // Bind the values to the query
             pstmt.setString(1, docId);
-            MetaCatUtil.debugMessage("docid is "+docId, 50);
+            logMetacat.info("docid is "+docId);
             pstmt.setString(2, docName);
-            MetaCatUtil.debugMessage("docname is "+docName, 50);
+            logMetacat.info("docname is "+docName);
             pstmt.setString(3, docType);
-            MetaCatUtil.debugMessage("docType is "+docType, 50);
+            logMetacat.info("docType is "+docType);
             pstmt.setString(4, user);
-            MetaCatUtil.debugMessage("onwer is "+user, 50);
+            logMetacat.info("onwer is "+user);
             pstmt.setString(5, user);
-            MetaCatUtil.debugMessage("update user is "+user, 50);
+            logMetacat.info("update user is "+user);
             pstmt.setInt(6, 0);
             pstmt.setInt(7, (new Integer(catalogid)).intValue());
-            MetaCatUtil.debugMessage("catalogid is "+catalogid, 50);
+            logMetacat.info("catalogid is "+catalogid);
             pstmt.setInt(8, serverCode);
-            MetaCatUtil.debugMessage("server code is "+serverCode, 50);
+            logMetacat.info("server code is "+serverCode);
             pstmt.setInt(9, Integer.parseInt(rev));
-            MetaCatUtil.debugMessage("rev is "+rev, 50);
+            logMetacat.info("rev is "+rev);
             
             if (rootNodeId >0 )
             {
               pstmt.setLong(10, rootNodeId);
-              MetaCatUtil.debugMessage("root id is "+rootNodeId, 50);
+              logMetacat.info("root id is "+rootNodeId);
             }
             // Do the insertion
             pstmt.execute();
             pstmt.close();
-            MetaCatUtil.debugMessage("end of write into revisons", 50);
+            logMetacat.info("end of write into revisons");
            
         } 
         catch (SQLException sqle) 
Index: src/edu/ucsb/nceas/metacat/AddMissedSubTreeSAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AddMissedSubTreeSAXHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AddMissedSubTreeSAXHandler.java	(revision 2663)
@@ -38,6 +38,7 @@
 import java.util.Enumeration;
 import java.util.EmptyStackException;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
@@ -62,7 +63,8 @@
    private static final String ID ="id";
    private static final String REFERENCES = "references";
    public  static final String INLINE = "inline";
-      
+   private Logger logMetacat = Logger.getLogger(AddMissedSubTreeSAXHandler.class);
+   
   
     /** Construct an instance of the handler class
     * In this constructor, user can specify the version need to upadate
@@ -118,9 +120,7 @@
    public void endElement(String uri, String localName,
                           String qName) throws SAXException 
   {
-     MetaCatUtil.logMetacat.info("End ELEMENT " + qName);
-
-   
+     logMetacat.info("End ELEMENT " + qName);
    }
    
 }
Index: src/edu/ucsb/nceas/metacat/ReplicationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/ReplicationHandler.java	(revision 2663)
@@ -35,6 +35,8 @@
 import java.io.*;
 import java.net.*;
 import java.text.*;
+
+import org.apache.log4j.Logger;
 import org.xml.sax.AttributeList;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.DTDHandler;
@@ -61,7 +63,7 @@
   ReplicationServerList serverList = null;
   //PrintWriter out;
   private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
-
+  private static Logger logMetacat = Logger.getLogger(ReplicationHandler.class);
  
   
   public ReplicationHandler()
@@ -99,8 +101,8 @@
     }//try
     catch (Exception e)
     {
-      MetaCatUtil.debugMessage("Error in replicationHandler.run():"
-                                                    +e.getMessage(), 30);
+      logMetacat.error("Error in replicationHandler.run():"
+                                                    +e.getMessage());
       e.printStackTrace();
     }//catch
   }
@@ -143,8 +145,8 @@
     {
       MetacatReplication.replErrorLog("Failed to replicate becaue couldn't "+
                                  " initParser for message and" +e.getMessage());
-      MetaCatUtil.debugMessage("Failed to replicate becaue couldn't " +
-                            " initParser for message and " +e.getMessage(), 30);
+      logMetacat.error("Failed to replicate becaue couldn't " +
+                            " initParser for message and " +e.getMessage());
        // stop replication
        return;
     }
@@ -163,7 +165,7 @@
         {
           u = new URL("https://" + server + "?server="
           +util.getLocalReplicationServerName()+"&action=update");
-          MetaCatUtil.debugMessage("Sending infomation " +u.toString(), 50);
+          logMetacat.info("Sending infomation " +u.toString());
           result = MetacatReplication.getURLContent(u);
         }
         catch (Exception e)
@@ -170,19 +172,19 @@
         {
           MetacatReplication.replErrorLog("Failed to get updated doc list "+
                           "for server " + server + " because "+e.getMessage());
-          MetaCatUtil.debugMessage( "Failed to get updated doc list "+
-                       "for server " + server + " because "+e.getMessage(), 30);
+          logMetacat.error( "Failed to get updated doc list "+
+                       "for server " + server + " because "+e.getMessage());
           continue;
         }
 
-        MetaCatUtil.debugMessage("docid: "+server+" "+result, 50);
+        logMetacat.info("docid: "+server+" "+result);
         //check if result have error or not, if has skip it.
         if (result.indexOf("<error>")!=-1 && result.indexOf("</error>")!=-1)
         {
           MetacatReplication.replErrorLog("Failed to get updated doc list "+
                           "for server " + server + " because "+result);
-          MetaCatUtil.debugMessage( "Failed to get updated doc list "+
-                       "for server " + server + " because "+result, 30);
+          logMetacat.info( "Failed to get updated doc list "+
+                       "for server " + server + " because "+result);
           continue;
         }
         //Add result to vector
@@ -195,14 +197,14 @@
     {
         MetacatReplication.replErrorLog("No updated doc list for "+
                            "every server and failed to replicate");
-        MetaCatUtil.debugMessage( "No updated doc list for "+
-                           "every server and failed to replicate", 30);
+        logMetacat.info( "No updated doc list for "+
+                           "every server and failed to replicate");
         return;
     }
 
 
-    MetaCatUtil.debugMessage("Responses from remote metacat about updated "+
-                   "document information: "+ responses.toString(), 35);
+    logMetacat.info("Responses from remote metacat about updated "+
+                   "document information: "+ responses.toString());
     // go through response vector(it contains updated vector and delete vector
     for(int i=0; i<responses.size(); i++)
     {
@@ -216,8 +218,8 @@
         {
           MetacatReplication.replErrorLog("Couldn't parse one responses "+
                            "because "+ e.getMessage());
-          MetaCatUtil.debugMessage("Couldn't parse one responses "+
-                                   "because "+ e.getMessage(), 30);
+          logMetacat.error("Couldn't parse one responses "+
+                                   "because "+ e.getMessage());
           continue;
         }
         //v is the list of updated documents
@@ -226,8 +228,8 @@
         //d is the list of deleted documents
         Vector deleteList = new Vector(message.getDeletesVect());
         //System.out.println("d: " + d.toString());
-        MetaCatUtil.debugMessage("Update vector size: "+ updateList.size(), 40);
-        MetaCatUtil.debugMessage("Delete vector size: "+ deleteList.size(),40);
+        logMetacat.info("Update vector size: "+ updateList.size());
+        logMetacat.info("Delete vector size: "+ deleteList.size());
         // go though every element in updated document vector
         handleDocList(updateList, DocumentImpl.DOCUMENTTABLE);
         //handle deleted docs
@@ -293,8 +295,8 @@
       {
          throw new Exception(newxmldoc);
       }
-      //MetaCatUtil.debugMessage("xml documnet:", 45);
-      //MetaCatUtil.debugMessage(newxmldoc, 45);
+      //logMetacat.info("xml documnet:");
+      //logMetacat.info(newxmldoc);
 
       // Try get the docid info from remote server
       DocInfoHandler dih = new DocInfoHandler();
@@ -304,22 +306,22 @@
                        "&action=getdocumentinfo&docid="+accNumber;
       docInfoURLStr = MetaCatUtil.replaceWhiteSpaceForURL(docInfoURLStr);
       URL docinfoUrl = new URL(docInfoURLStr);
-      MetaCatUtil.debugMessage("Sending message: " +
-                                                  docinfoUrl.toString(), 45);
+      logMetacat.info("Sending message: " +
+                                                  docinfoUrl.toString());
       String docInfoStr = MetacatReplication.getURLContent(docinfoUrl);
       docinfoParser.parse(new InputSource(new StringReader(docInfoStr)));
       Hashtable docinfoHash = dih.getDocInfo();
       // Get home server of the docid
       String docHomeServer = (String)docinfoHash.get("home_server");
-      MetaCatUtil.debugMessage("doc home server in repl: "+docHomeServer, 45);
+      logMetacat.info("doc home server in repl: "+docHomeServer);
       String createdDate = (String)docinfoHash.get("date_created");
       String updatedDate = (String)docinfoHash.get("date_updated");
       //docid should include rev number too
       /*String accnum=docId+util.getOption("accNumSeparator")+
                                               (String)docinfoHash.get("rev");*/
-      MetaCatUtil.debugMessage("docid in repl: "+accNumber, 45);
+      logMetacat.info("docid in repl: "+accNumber);
       String docType = (String)docinfoHash.get("doctype");
-      MetaCatUtil.debugMessage("doctype in repl: "+docType, 45);
+      logMetacat.info("doctype in repl: "+docType);
 
       String parserBase = null;
       // this for eml2 and we need user eml2 parser
@@ -349,7 +351,7 @@
                               remoteserver, tableName, true,// true is for time replication 
                               createdDate,
                               updatedDate);
-      MetaCatUtil.debugMessage("Successfully replicated doc " + accNumber, 35);
+      logMetacat.info("Successfully replicated doc " + accNumber);
       MetacatReplication.replLog("wrote doc " + accNumber + " from " +
                                          remoteserver);
 
@@ -358,8 +360,8 @@
     {
       MetacatReplication.replErrorLog("Failed to write doc " + accNumber +
                                       " into db because " +e.getMessage());
-      MetaCatUtil.debugMessage("Failed to write doc " + accNumber +
-                                      " into db because " +e.getMessage(), 30);
+      logMetacat.error("Failed to write doc " + accNumber +
+                                      " into db because " +e.getMessage());
       throw e;
     }
     finally
@@ -376,7 +378,7 @@
                                     String accNumber, String tableName)
                throws Exception
   {
-    MetaCatUtil.debugMessage("Try to replicate data file: "+accNumber, 40);
+    logMetacat.info("Try to replicate data file: "+accNumber);
     DBConnection dbConn = null;
     int serialNumber = -1;
     try
@@ -436,13 +438,13 @@
                                                 createdDate,
                                                 updatedDate);
                                          
-        MetaCatUtil.debugMessage("Successfully to write datafile " + accNumber, 30);
+        logMetacat.info("Successfully to write datafile " + accNumber);
         MetacatReplication.replLog("wrote datafile " + accNumber + " from " +
                                     remoteserver);
       }//if
       else
       {
-         MetaCatUtil.debugMessage("Couldn't open the data file: " + accNumber, 30);
+         logMetacat.info("Couldn't open the data file: " + accNumber);
          throw new Exception("Couldn't open the data file: " + accNumber);
       }//else
 
@@ -451,8 +453,8 @@
     {
       MetacatReplication.replErrorLog("Failed to try wrote datafile " + accNumber +
                                       " because " +e.getMessage());
-      MetaCatUtil.debugMessage("Failed to try wrote datafile " + accNumber +
-                                      " because " +e.getMessage(), 30);
+      logMetacat.error("Failed to try wrote datafile " + accNumber +
+                                      " because " +e.getMessage());
       throw e;
     }
     finally
@@ -468,7 +470,7 @@
   private void handleDeleteSingleDocument(String docId, String notifyServer)
                throws Exception
   {
-    MetaCatUtil.debugMessage("Try delete doc: "+docId, 40);
+    logMetacat.info("Try delete doc: "+docId);
     DBConnection dbConn = null;
     int serialNumber = -1;
     try
@@ -485,7 +487,7 @@
          String accnum=docId+util.getOption("accNumSeparator")+"1";
          //System.out.println("accnum: "+accnum);
          DocumentImpl.delete(accnum, null, null, notifyServer);
-         MetaCatUtil.debugMessage("Successfully deleted doc " + docId, 30);
+         logMetacat.info("Successfully deleted doc " + docId);
          MetacatReplication.replLog("Doc " + docId + " deleted");
       }
 
@@ -494,8 +496,8 @@
     {
       MetacatReplication.replErrorLog("Failed to delete doc " + docId +
                                       " in db because " +e.getMessage());
-      MetaCatUtil.debugMessage("Failed to delete doc " + docId +
-                                 " in db because because " +e.getMessage(), 30);
+      logMetacat.error("Failed to delete doc " + docId +
+                                 " in db because because " + e.getMessage());
       throw e;
     }
     finally
@@ -520,12 +522,12 @@
              getDBConnection("ReplicationHandler.updateLastCheckTimeForServer");
       serialNumber=dbConn.getCheckOutSerialNumber();
 
-      MetaCatUtil.debugMessage("Try to update last_check for server: "+server, 40);
+      logMetacat.info("Try to update last_check for server: "+server);
       // Get time from remote server
       URL dateurl = new URL("https://" + server + "?server="+
       util.getLocalReplicationServerName()+"&action=gettime");
       String datexml = MetacatReplication.getURLContent(dateurl);
-      MetaCatUtil.debugMessage("datexml: "+datexml, 45);
+      logMetacat.info("datexml: "+datexml);
       if (datexml!=null && !datexml.equals(""))
       {
          String datestr = datexml.substring(11, datexml.indexOf('<', 11));
@@ -541,15 +543,15 @@
          pstmt.executeUpdate();
          dbConn.commit();
          pstmt.close();
-         MetaCatUtil.debugMessage("last_checked updated to "+datestr+" on "
-                                      + server, 45);
+         logMetacat.info("last_checked updated to "+datestr+" on "
+                                      + server);
       }//if
       else
       {
 
-         MetaCatUtil.debugMessage("Failed to update last_checked for server "  +
+         logMetacat.info("Failed to update last_checked for server "  +
                                   server + " in db because couldn't get time "
-                                  , 30);
+                                  );
          throw new Exception("Couldn't get time for server "+ server);
       }
 
@@ -557,9 +559,9 @@
     catch(Exception e)
     {
 
-      MetaCatUtil.debugMessage("Failed to update last_checked for server " +
+      logMetacat.error("Failed to update last_checked for server " +
                                 server + " in db because because " +
-                                e.getMessage(), 30);
+                                e.getMessage());
       throw e;
     }
     finally
@@ -576,7 +578,7 @@
    */
   private void updateCatalog()
   {
-    MetaCatUtil.debugMessage("Start of updateCatalog", 35 );
+    logMetacat.info("Start of updateCatalog");
     // ReplicationServer object in server list
     ReplicationServer replServer = null;
     PreparedStatement pstmt = null;
@@ -597,7 +599,7 @@
         // Try to get catalog
         URL u = new URL("https://" + server + "?server="+
         util.getLocalReplicationServerName()+"&action=getcatalog");
-        MetaCatUtil.debugMessage("sending message " + u.toString(), 50);
+        logMetacat.info("sending message " + u.toString());
         String catxml = MetacatReplication.getURLContent(u);
 
         // Make sure there are not error, no empty string
@@ -605,7 +607,7 @@
         {
           throw new Exception("Couldn't get catalog list form server " +server);
         }
-        MetaCatUtil.debugMessage("catxml: " + catxml, 40);
+        logMetacat.info("catxml: " + catxml);
         CatalogMessageHandler cmh = new CatalogMessageHandler();
         XMLReader catparser = initParser(cmh);
         catparser.parse(new InputSource(new StringReader(catxml)));
@@ -639,7 +641,7 @@
         for(int i=0; i<localCatalog.size(); i++)
         {
           Vector v = new Vector((Vector)localCatalog.elementAt(i));
-          MetaCatUtil.debugMessage("v1: " + v.toString(), 50);
+          logMetacat.info("v1: " + v.toString());
           publicId.add(new String((String)v.elementAt(3)));
           //System.out.println("adding " + (String)v.elementAt(3));
         }
@@ -648,8 +650,8 @@
       {
         MetacatReplication.replErrorLog("Failed to update catalog for server "+
                                     server + " because " +e.getMessage());
-        MetaCatUtil.debugMessage("Failed to update catalog for server "+
-                                    server + " because " +e.getMessage(), 30);
+        logMetacat.error("Failed to update catalog for server "+
+                                    server + " because " +e.getMessage());
       }//catch
 
       for(int i=0; i<remoteCatalog.size(); i++)
@@ -668,8 +670,8 @@
             //System.out.println("i: " + i);
             //System.out.println("remoteCatalog.size(): " + remoteCatalog.size());
             //System.out.println("publicID: " + publicId.toString());
-            MetaCatUtil.debugMessage
-                              ("v.elementAt(3): " + (String)v.elementAt(3), 50);
+            logMetacat.info
+                              ("v.elementAt(3): " + (String)v.elementAt(3));
            if(!publicId.contains(v.elementAt(3)))
            { //so we don't have this public id in our local table so we need to
              //add it.
@@ -689,8 +691,8 @@
              pstmt.close();
              MetacatReplication.replLog("Success fully to insert new publicid "+
                                (String)v.elementAt(3) + " from server"+server);
-             MetaCatUtil.debugMessage("Success fully to insert new publicid "+
-                             (String)v.elementAt(3) + " from server" +server, 30);
+             logMetacat.info("Success fully to insert new publicid "+
+                             (String)v.elementAt(3) + " from server" +server);
            }
         }
         catch(Exception e)
@@ -697,8 +699,8 @@
         {
            MetacatReplication.replErrorLog("Failed to update catalog for server "+
                                     server + " because " +e.getMessage());
-           MetaCatUtil.debugMessage("Failed to update catalog for server "+
-                                    server + " because " +e.getMessage(), 30);
+           logMetacat.error("Failed to update catalog for server "+
+                                    server + " because " +e.getMessage());
         }//catch
         finally
         {
@@ -706,7 +708,7 @@
         }//finall
       }//for remote catalog
     }//for server list
-    MetaCatUtil.debugMessage("End of updateCatalog", 35);
+    logMetacat.info("End of updateCatalog");
   }
 
   /**
@@ -780,8 +782,8 @@
     }
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("error in ReplicationHandler.alreadyDeleted: " +
-                          e.getMessage(), 30);
+      logMetacat.error("error in ReplicationHandler.alreadyDeleted: " +
+                          e.getMessage());
       throw e;
     }
     finally
@@ -792,8 +794,8 @@
       }//try
       catch (SQLException ee)
       {
-        MetaCatUtil.debugMessage("Error in replicationHandler.alreadyDeleted "+
-                          "to close pstmt: "+ee.getMessage(), 30);
+        logMetacat.error("Error in replicationHandler.alreadyDeleted "+
+                          "to close pstmt: "+ee.getMessage());
         throw ee;
       }//catch
       finally
@@ -854,7 +856,7 @@
      Date currentTime = parseTime(currentTimeString); 
      if ( currentTime.getTime() >= givenDate.getTime())
      {
-        MetaCatUtil.debugMessage("Today already pass the given time, we should set it as tomorrow", 30);
+        logMetacat.info("Today already pass the given time, we should set it as tomorrow");
         String dateAndTime = getDateString(now) + " " + givenTime;
         Date combinationDate = parseDateTime(dateAndTime);
         // new date should plus 24 hours to make is the second day
@@ -862,11 +864,11 @@
      }
      else
      {
-         MetaCatUtil.debugMessage("Today haven't pass the given time, we should it as today", 2);
+         logMetacat.info("Today haven't pass the given time, we should it as today");
          String dateAndTime = getDateString(now) + " " + givenTime;
          newDate = parseDateTime(dateAndTime);
      }
-     MetaCatUtil.debugMessage("final setting time is "+ newDate.toString(), 20);
+     logMetacat.warn("final setting time is "+ newDate.toString());
      return newDate;
   }
 
@@ -879,8 +881,8 @@
   {
     DateFormat format = DateFormat.getTimeInstance(DateFormat.SHORT);
     Date time = format.parse(timeString); 
-    MetaCatUtil.debugMessage("Date string is after parse a time string "
-                              +time.toString(), 50);
+    logMetacat.info("Date string is after parse a time string "
+                              +time.toString());
     return time;
 
   }
@@ -893,8 +895,8 @@
   {
     DateFormat format = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);
     Date time = format.parse(timeString);
-    MetaCatUtil.debugMessage("Date string is after parse a time string "+
-                             time.toString(), 50);
+    logMetacat.info("Date string is after parse a time string "+
+                             time.toString());
     return time;
   }
   
@@ -905,7 +907,7 @@
   {
      DateFormat df = DateFormat.getDateInstance(DateFormat.LONG);
      String s = df.format(now);
-     MetaCatUtil.debugMessage("Today is " + s, 50);
+     logMetacat.info("Today is " + s);
      return s;
   }
   
@@ -916,7 +918,7 @@
   {
      DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
      String s = df.format(now);
-     MetaCatUtil.debugMessage("Time is " + s, 50);
+     logMetacat.info("Time is " + s);
      return s;
   }
   
@@ -945,10 +947,10 @@
          //System.out.println("w: " + w.toString());
          // Get docid
          String docid = (String)w.elementAt(0);
-         MetaCatUtil.debugMessage("docid: " + docid, 40);
+         logMetacat.info("docid: " + docid);
          // Get revision number
          int rev = Integer.parseInt((String)w.elementAt(1));
-         MetaCatUtil.debugMessage("rev: " + rev, 40);
+         logMetacat.info("rev: " + rev);
          // Get remote server name (it is may not be doc homeserver because
          // the new hub feature
          String remoteServer = (String)w.elementAt(2);
@@ -972,8 +974,8 @@
          }
          catch (Exception e)
          {
-             MetaCatUtil.debugMessage("error to handle update doc in "+ 
-                     tableName +" in time replication"+e.getMessage(), 30);
+             logMetacat.error("error to handle update doc in "+ 
+                     tableName +" in time replication"+e.getMessage());
              continue;
          }
         
@@ -997,14 +999,14 @@
        }
        catch (SQLException e)
        {
-         MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+
-                                " be found because " + e.getMessage(), 45);
+         logMetacat.error("Local rev for docid "+ docid + " could not "+
+                                " be found because " + e.getMessage());
          MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+
                  "written because error happend to find it's local revision");
          throw new Exception (e.getMessage());
        }
-       MetaCatUtil.debugMessage("Local rev for docid "+ docid + " is "+
-                               localrev, 45);
+       logMetacat.info("Local rev for docid "+ docid + " is "+
+                               localrev);
 
        //check the revs for an update because this document is in the
        //local DB, it might be out of date.
@@ -1068,9 +1070,9 @@
                                         throws Exception
    {
        // compare the update rev and local rev to see what need happen
-       MetaCatUtil.debugMessage("In handle repliation revsion table", 50);
-       MetaCatUtil.debugMessage("the docid is "+ docid, 50);
-       MetaCatUtil.debugMessage("The rev is "+rev, 50);
+       logMetacat.info("In handle repliation revsion table");
+       logMetacat.info("the docid is "+ docid);
+       logMetacat.info("The rev is "+rev);
        Vector localrev = null;
        String action = "INSERT";
        boolean flag = false;
@@ -1080,14 +1082,14 @@
        }
        catch (SQLException e)
        {
-         MetaCatUtil.debugMessage("Local rev for docid "+ docid + " could not "+
-                                " be found because " + e.getMessage(), 45);
+         logMetacat.error("Local rev for docid "+ docid + " could not "+
+                                " be found because " + e.getMessage());
          MetacatReplication.replErrorLog("Docid "+ docid + " could not be "+
                  "written because error happend to find it's local revision");
          throw new Exception (e.getMessage());
        }
-       MetaCatUtil.debugMessage("rev list in xml_revision table for docid "+ docid + " is "+
-                               localrev.toString(), 45);
+       logMetacat.info("rev list in xml_revision table for docid "+ docid + " is "+
+                               localrev.toString());
        
        // if the rev is not in the xml_revision, we need insert it
        if (!localrev.contains(new Integer(rev)))
Index: src/edu/ucsb/nceas/metacat/DBSAXNode.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBSAXNode.java	(revision 2663)
@@ -32,6 +32,7 @@
 import java.util.Hashtable;
 import java.util.Enumeration;
 //import oracle.jdbc.driver.*;
+import org.apache.log4j.Logger;
 import org.xml.sax.SAXException;
 
 import edu.ucsb.nceas.dbadapter.AbstractDatabase;
@@ -45,6 +46,7 @@
   private DBConnection	connection;
   private DBSAXNode	parentNode;
   private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
+  private Logger logMetacat = Logger.getLogger(DBSAXNode.class);
 
   /**
    * Construct a new node instance for DOCUMENT nodes
@@ -144,7 +146,7 @@
 
         // Increase DBConnection usage count
         connection.increaseUsageCount(1);
-        MetaCatUtil.debugMessage("INSERTING DOCNAME: " + nodename, 35);
+        logMetacat.info("INSERTING DOCNAME: " + nodename);
       } else {
           if(data != null && !data.trim().equals("")
              && !data.trim().equals("NaN")){
@@ -296,7 +298,7 @@
     {
 
       PreparedStatement pstmt;
-      MetaCatUtil.debugMessage("Insert dtd into db: "+nodename +" "+data, 45);
+      logMetacat.info("Insert dtd into db: "+nodename +" "+data);
       if(data != null && !data.trim().equals("")){
             try{
                 double numberData = Double.parseDouble(data);
Index: src/edu/ucsb/nceas/metacat/RelationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/RelationHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/RelationHandler.java	(revision 2663)
@@ -28,13 +28,16 @@
 import java.util.*;
 import java.net.*;
 
+import org.apache.log4j.Logger;
 
+
 public class RelationHandler //implements Runnable
 {
   private DBConnection connection = null;
   private String docid = null;
   private String docType = null;
-  
+  private static Logger logMetacat = Logger.getLogger(RelationHandler.class);
+
   TripleCollection tripleForPackage = null;
    
   /** 
@@ -73,7 +76,7 @@
     String objDoctype = null;
     PreparedStatement tstmt = null; // to insert each relation into xml_relation
    
-    MetaCatUtil.debugMessage("Running relation handler!", 40);
+    logMetacat.info("Running relation handler!");
    
     // first delete the relations for this package document if any
     deleteRelations(docid);
@@ -101,10 +104,10 @@
         connection.increaseUsageCount(1);
         // Get the triple
         Triple triple = (Triple)tripleList.elementAt(i);
-        MetaCatUtil.debugMessage("Info from triple: ", 30);
-        MetaCatUtil.debugMessage("subject from triple:"+triple.getSubject(), 30);
-        MetaCatUtil.debugMessage("relationship from triple:"+triple.getRelationship(),30);
-        MetaCatUtil.debugMessage("object from triple: "+triple.getObject(),30);
+        logMetacat.info("Info from triple: ");
+        logMetacat.info("subject from triple:"+triple.getSubject());
+        logMetacat.info("relationship from triple:"+triple.getRelationship());
+        logMetacat.info("object from triple: "+triple.getObject());
         //subject = (new DocumentIdentifier(triple.getSubject())).getIdentifier();
         subject = MetaCatUtil.getDocIdFromString(triple.getSubject());
         relationship = triple.getRelationship();
@@ -115,21 +118,21 @@
         {
         
           //put the new relation into xml_relation
-          MetaCatUtil.debugMessage("Insert into xml_relation table", 30);
+          logMetacat.info("Insert into xml_relation table");
           tstmt.setString(1, docid);
-          MetaCatUtil.debugMessage("Insert docid into xml_relation table" + 
-                                docid, 30);
+          logMetacat.info("Insert docid into xml_relation table" + 
+                                docid);
           tstmt.setString(2, packagetype);
           tstmt.setString(3, subject);
-          MetaCatUtil.debugMessage("Insert subject into xml_relation table" + 
-                               subject, 30);
+          logMetacat.info("Insert subject into xml_relation table" + 
+                               subject);
           tstmt.setString(4, subDoctype);
           tstmt.setString(5, relationship);
-          MetaCatUtil.debugMessage("Insert relationship into xml_relation table" + 
-                                relationship, 30);
+          logMetacat.info("Insert relationship into xml_relation table" + 
+                                relationship);
           tstmt.setString(6, object);
-          MetaCatUtil.debugMessage("Insert object into xml_relation table" + 
-                                object, 30);
+          logMetacat.info("Insert object into xml_relation table" + 
+                                object);
           tstmt.setString(7, objDoctype);
           tstmt.execute();  
         }//if
@@ -160,8 +163,8 @@
       pstmt.execute();
       pstmt.close();
     } catch(SQLException e) {
-      MetaCatUtil.debugMessage("error in RelationHandler.deleteRelations(): " + 
-                          e.getMessage(), 30);
+      logMetacat.error("error in RelationHandler.deleteRelations(): " + 
+                          e.getMessage());
       
       throw e;
     }
@@ -226,8 +229,8 @@
       }//finally
     }//finally
      
-    MetaCatUtil.debugMessage("The access docid get from xml_relation is: "+
-                              aclid, 30);
+    logMetacat.info("The access docid get from xml_relation is: "+
+                              aclid);
     return aclid;
   }
 
Index: src/edu/ucsb/nceas/metacat/DBUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBUtil.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBUtil.java	(revision 2663)
@@ -46,6 +46,8 @@
 import java.util.Vector;
 import java.util.Stack;
 
+import org.apache.log4j.Logger;
+
 /**
  * A suite of utility classes for quering DB
  */
@@ -52,6 +54,7 @@
 public class DBUtil {
 
   //private Connection	conn = null;
+  private static Logger logMetacat = Logger.getLogger(DBUtil.class);
 
   /**
    * main routine used for testing.
@@ -458,8 +461,8 @@
     catch ( SQLException e)
     {
       // Print out excepition
-      MetaCatUtil.debugMessage("Error in DBUil.findDataSEtDocIdForGivenDocument"
-                                +e.getMessage(), 30);
+      logMetacat.error("Error in DBUil.findDataSEtDocIdForGivenDocument"
+                                +e.getMessage());
       // return null
       return dataSetDocId;
      
@@ -476,8 +479,8 @@
       catch ( SQLException e)
       {
         // Print out excepition
-        MetaCatUtil.debugMessage("Error in DBUil.findDataSetDocIdForGivenDoc"
-                                + e.getMessage(), 30);
+    	  logMetacat.error("Error in DBUil.findDataSetDocIdForGivenDoc"
+                                + e.getMessage());
      
       }//catch
       finally
@@ -559,8 +562,8 @@
       catch ( SQLException e)
       {
         // Print out excepition
-        MetaCatUtil.debugMessage("Error in DBUil.getCurrentRevisionAndDocType"
-                                + e.getMessage(), 30);
+    	  logMetacat.error("Error in DBUil.getCurrentRevisionAndDocType"
+                                + e.getMessage());
      
       }//catch
       finally
@@ -602,7 +605,7 @@
           boolean hasRow = rs.next();
           while (hasRow) {
               rev = rs.getInt(1);
-              MetaCatUtil.debugMessage("rev "+ rev +" is added to list", 20);
+              logMetacat.warn("rev "+ rev +" is added to list");
               list.add(new Integer(rev));
               hasRow = rs.next();
               
@@ -613,8 +616,8 @@
           try {
               pStmt.close();
           } catch (Exception ee) {
-              MetaCatUtil.debugMessage("Error in DocumentImpl."
-                      + "getLatestRevisionNumber: " + ee.getMessage(), 50);
+        	  logMetacat.error("Error in DocumentImpl."
+                      + "getLatestRevisionNumber: " + ee.getMessage());
           } finally {
               DBConnectionPool.returnDBConnection(dbConn, serialNumber);
           }
@@ -662,8 +665,8 @@
           try {
               pStmt.close();
           } catch (Exception ee) {
-              MetaCatUtil.debugMessage("Error in DBUtil."
-                      + "getLatestRevisionInDocumentTable: " + ee.getMessage(), 50);
+        	  logMetacat.error("Error in DBUtil."
+                      + "getLatestRevisionInDocumentTable: " + ee.getMessage());
           } finally {
               DBConnectionPool.returnDBConnection(dbConn, serialNumber);
           }
Index: src/edu/ucsb/nceas/metacat/ForceReplicationHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ForceReplicationHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/ForceReplicationHandler.java	(revision 2663)
@@ -38,6 +38,8 @@
 import java.lang.*;
 import java.text.*;
 
+import org.apache.log4j.Logger;
+
 /**
  * A class to asyncronously force the replication of each server
  * that has an entry in the xml_replication table.  When run,
@@ -60,6 +62,7 @@
   // other metacat in its serverlist to update this docid if A is a hub. But we
   // don't want A to notify B again. B is nofitification of A
   private String notificationServer = null;
+  private Logger logMetacat = Logger.getLogger(ForceReplicationHandler.class);
 
   //constant
   public static final String DELETE = "delete";
@@ -92,8 +95,8 @@
     }//try
     catch (Exception e)
     {
-      MetaCatUtil.debugMessage("Error in ForceReplicationHandle(): "
-                                                          +e.getMessage(), 30);
+      logMetacat.error("Error in ForceReplicationHandle(): "
+                                                          +e.getMessage());
     }//catch
     // Get the notification server
     this.notificationServer = myNotificationServer;
@@ -126,8 +129,8 @@
     }
      catch (Exception e)
     {
-      MetaCatUtil.debugMessage("Error in ForceReplicationHandle(): "
-                                                          +e.getMessage(), 30);
+      logMetacat.error("Error in ForceReplicationHandle(): "
+                                                          +e.getMessage());
     }//catch
     // Get notification server
     this.notificationServer = myNotificationServer;
@@ -162,9 +165,9 @@
       }
       catch(Exception ee)
       {
-        MetaCatUtil.debugMessage("Couldn't sleep in force replication", 20);
+        logMetacat.error("Couldn't sleep in force replication");
       }
-      MetaCatUtil.debugMessage("notification server:"+notificationServer, 34);
+      logMetacat.info("notification server:"+notificationServer);
       // Check every server in the serverlists
       for (int i=0; i<serverLists.size(); i++)
       {
@@ -343,8 +346,8 @@
           //Make sure comeAndGetIt is not empty
           if ( comeAndGetIt != null && !comeAndGetIt.equals(""))
           {
-            MetaCatUtil.debugMessage("sending message: "
-                                                + comeAndGetIt.toString(), 25);
+            logMetacat.warn("sending message: "
+                                                + comeAndGetIt.toString());
             String message = MetacatReplication.getURLContent(comeAndGetIt);
           }
           //send out the url.  message is a dummy variable as the target of
@@ -354,13 +357,13 @@
         }
         catch (Exception ee)
         {
-            MetaCatUtil.debugMessage("error in ForceReplicationHandler.run for server " 
-                    + server +" "+ee.getMessage(), 20);
+        	logMetacat.error("error in ForceReplicationHandler.run for server " 
+                    + server +" "+ee.getMessage());
              ee.printStackTrace();
         }
       }//for
 
    
-      MetaCatUtil.debugMessage("exiting ForceReplicationHandler Thread", 25);
+      logMetacat.warn("exiting ForceReplicationHandler Thread");
   }//run
 }//ForceReplication class
Index: src/edu/ucsb/nceas/metacat/AccessSection.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AccessSection.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AccessSection.java	(revision 2663)
@@ -31,6 +31,8 @@
 import java.util.Vector;
 import java.util.Stack;
 
+import org.apache.log4j.Logger;
+
 /**
  * A Class that represents an XML access rule. It include principal and
  * permission
@@ -45,6 +47,7 @@
   private Stack storedTmpNodeStack = null;
   private Vector describedIdList = new Vector();
   private long startedDescribesNodeId = -1;
+  private Logger logMetacat = Logger.getLogger(AccessSection.class);
 
 
     /**
@@ -148,7 +151,7 @@
     {
 
       // set parameters
-      MetaCatUtil.logMetacat.info("Copy permission order: " +
+      logMetacat.info("Copy permission order: " +
                                 this.getPermissionOrder());
       newAccessSection.setPermissionOrder(this.getPermissionOrder());
       Vector accessRuleVector = this.getAccessRules();
Index: src/edu/ucsb/nceas/metacat/FilteredSubTree.java
===================================================================
--- src/edu/ucsb/nceas/metacat/FilteredSubTree.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/FilteredSubTree.java	(revision 2663)
@@ -37,7 +37,9 @@
 import java.sql.SQLException;
 import java.sql.ResultSet;
 
+import org.apache.log4j.Logger;
 
+
 /**
  * A Class that represents an Filtered XML Subtree, it means a subtree which 
  * contains another subtree has different access behavor to it.
@@ -52,7 +54,7 @@
   private long   startNodeId = -1;
   private long   endNodeId =   -1;
   private Vector sortedFilteredSubTree = new Vector();
- 
+  private Logger logMetacat = Logger.getLogger(FilteredSubTree.class);
     
     /**
      * Constructor of filteredsubtree
@@ -62,14 +64,14 @@
                   throws McdbException
     {
       this.docId = myDocId;
-      MetaCatUtil.debugMessage("Docid of FilteredSubtree: " + docId, 30);
+      logMetacat.info("Docid of FilteredSubtree: " + docId);
       this.subTreeId = mySubTreeId;
-      MetaCatUtil.debugMessage("id of FilteredSubtree: " + subTreeId, 30);
+      logMetacat.info("id of FilteredSubtree: " + subTreeId);
       this.startNodeId = myStartNodeId;
-      MetaCatUtil.debugMessage("start node id of FilteredSubtree: " + 
-                                startNodeId, 30);
+      logMetacat.info("start node id of FilteredSubtree: " + 
+                                startNodeId);
       this.endNodeId = myEndNodeId;
-      MetaCatUtil.debugMessage("end node id of FilteredSubtree: " + endNodeId, 30);
+      logMetacat.info("end node id of FilteredSubtree: " + endNodeId);
      }
     
   
@@ -77,7 +79,7 @@
     /** Set the a docId */
     public void setDocId(String myId)
     {
-      MetaCatUtil.debugMessage("set doc id: "+myId, 35);
+      logMetacat.info("set doc id: "+myId);
       this.docId = myId;
     }
 
@@ -91,7 +93,7 @@
     /** Set the a subtreeId */
     public void setSubTreeId(String myId)
     {
-      MetaCatUtil.debugMessage("set sub tree id: "+myId, 35);
+      logMetacat.info("set sub tree id: "+myId);
       this.subTreeId = myId;
     }
 
@@ -106,7 +108,7 @@
      */
     public void setStartElementName(String elementName) 
     {
-      MetaCatUtil.debugMessage("set start elementname: "+elementName, 35);
+      logMetacat.info("set start elementname: "+elementName);
       this.startElementName = elementName;
     }
     
@@ -121,7 +123,7 @@
     /** Set a start node id */
     public void setStartNodeId(long nodeId)
     {
-      MetaCatUtil.debugMessage("set start node id: "+nodeId, 35);
+      logMetacat.info("set start node id: "+nodeId);
       this.startNodeId = nodeId;
     }
     
@@ -134,7 +136,7 @@
     /** Set a end node id */
     public void setEndNodeId(long nodeId)
     {
-      MetaCatUtil.debugMessage("set end node id: "+nodeId, 35);
+      logMetacat.info("set end node id: "+nodeId);
       this.endNodeId = nodeId;
     }
     
@@ -187,8 +189,8 @@
          sql = sql + "nodeid < ? ) OR (nodeid > ? AND "; 
        }
        sql = sql + "nodeid <= ? )) ORDER BY nodeid DESC";
-       MetaCatUtil.debugMessage("sql command for selecting filtere subtree is: "
-                                 +sql, 25);
+       logMetacat.info("sql command for selecting filtere subtree is: "
+                                 +sql);
        
        try 
        {
@@ -258,8 +260,8 @@
         }
         catch (SQLException ee)
         {
-          MetaCatUtil.debugMessage("error in FilteredSubTree.getSubTreeNodeList 2: "
-                                    +ee.getMessage(), 30);
+          logMetacat.error("error in FilteredSubTree.getSubTreeNodeList 2: "
+                                    +ee.getMessage());
         }
         finally
         {
Index: src/edu/ucsb/nceas/metacat/DBConnectionPool.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBConnectionPool.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBConnectionPool.java	(revision 2663)
@@ -36,6 +36,8 @@
 import java.util.Hashtable;
 import java.util.Enumeration;
 
+import org.apache.log4j.Logger;
+
 /** 
  * A class represent a DBConnection pool. Another user can use the
  * object to initial a connection pool, get db connection or return it.
@@ -50,7 +52,8 @@
   private static Vector connectionPool;
   private static Thread runner;
   private static int countOfReachMaximum = 0;
-  
+  private static Logger logMetacat = Logger.getLogger(DBConnectionPool.class);
+
   //maximum connection number in the connection pool
   final static int MAXIMUMCONNECTIONNUMBER=
                   Integer.parseInt(MetaCatUtil.getOption("maximumConnections"));
@@ -92,22 +95,22 @@
   public static synchronized DBConnectionPool getInstance()
                                  throws SQLException 
   {
-    MetaCatUtil.debugMessage
-                      ("MaximumConnectionNumber: "+MAXIMUMCONNECTIONNUMBER, 49);
-    MetaCatUtil.debugMessage
-                     ("Intial connection number: "+INITIALCONNECTIONNUMBER, 49);
-    MetaCatUtil.debugMessage
-                 ("Increated connection Number: "+INCREASECONNECTIONNUMBER, 49);
-    MetaCatUtil.debugMessage
-                  ("Maximum connection age: "+MAXIMUMAGE, 49);
-    MetaCatUtil.debugMessage
-                  ("Maximum connection time: "+MAXIMUMCONNECTIONTIME, 49);
-    MetaCatUtil.debugMessage
-                  ("Maximum usage count: "+MAXIMUMUSAGENUMBER, 49);
-    MetaCatUtil.debugMessage
-             ("Running recycle thread or not: "+DBCONNECTIONRECYCLETHREAD, 49);
-    MetaCatUtil.debugMessage
-             ("Cycle time of recycle: "+CYCLETIMEOFDBCONNECTION, 49); 
+    MetaCatUtil.printMessage
+                      ("MaximumConnectionNumber: "+MAXIMUMCONNECTIONNUMBER);
+    MetaCatUtil.printMessage
+                     ("Intial connection number: "+INITIALCONNECTIONNUMBER);
+    MetaCatUtil.printMessage
+                 ("Increated connection Number: "+INCREASECONNECTIONNUMBER);
+    MetaCatUtil.printMessage
+                  ("Maximum connection age: "+MAXIMUMAGE);
+    MetaCatUtil.printMessage
+                  ("Maximum connection time: "+MAXIMUMCONNECTIONTIME);
+    MetaCatUtil.printMessage
+                  ("Maximum usage count: "+MAXIMUMUSAGENUMBER);
+    MetaCatUtil.printMessage
+             ("Running recycle thread or not: "+DBCONNECTIONRECYCLETHREAD);
+    MetaCatUtil.printMessage
+             ("Cycle time of recycle: "+CYCLETIMEOFDBCONNECTION); 
     if (instance == null) {
       instance = new DBConnectionPool();
     }
@@ -194,9 +197,9 @@
     int random = 0; //random number
     int index = 0; //index
     int size = 0; //size of connection pool
-    MetaCatUtil.debugMessage("Try to checking out connection...", 65);
+    logMetacat.debug("Try to checking out connection...");
     size = connectionPool.size();
-    MetaCatUtil.debugMessage("size of connection pool: "+size, 55);
+    logMetacat.debug("size of connection pool: "+size);
     
      //try every DBConnection in the pool
     //every DBConnection will be try LIMITE times
@@ -209,9 +212,9 @@
       {
         index =(i+random)%size;
         db = (DBConnection) connectionPool.elementAt(index);
-        MetaCatUtil.debugMessage("Index: "+index, 65);
-        MetaCatUtil.debugMessage("Tag: "+db.getTag(), 65);
-        MetaCatUtil.debugMessage("Status: "+db.getStatus(), 65);
+        logMetacat.debug("Index: "+index);
+        logMetacat.debug("Tag: "+db.getTag());
+        logMetacat.debug("Status: "+db.getStatus());
         //check if the connection is free
         if (db.getStatus()==FREE)
         {
@@ -229,14 +232,14 @@
             db.setCheckOutMethodName(methodName);
             db.setAutoCommit(true);
             //debug message
-            MetaCatUtil.debugMessage("The connection is checked out: "
-                                       +db.getTag(), 65);
-            MetaCatUtil.debugMessage("The method for checking is: " 
-                                              +db.getCheckOutMethodName(), 65);
-            MetaCatUtil.debugMessage("The age is "+db.getAge(), 65);
-            MetaCatUtil.debugMessage("The usage is "+db.getUsageCount(), 65);
-            MetaCatUtil.debugMessage("The conection time it has: "
-                                                +db.getConnectionTime(), 65);
+            logMetacat.debug("The connection is checked out: "
+                                       +db.getTag());
+            logMetacat.debug("The method for checking is: " 
+                                              +db.getCheckOutMethodName());
+            logMetacat.debug("The age is "+db.getAge());
+            logMetacat.debug("The usage is "+db.getUsageCount());
+            logMetacat.debug("The conection time it has: "
+                                                +db.getConnectionTime());
             //set check out time
             db.setCheckOutTime(System.currentTimeMillis());
             // set count of reach maximum 0 because it can check out
@@ -290,15 +293,15 @@
                             " open db connections is reached." +
                             " New db connection to MetaCat" +
                             " cannot be established.");*/
-       MetaCatUtil.debugMessage("The maximum of " +MAXIMUMCONNECTIONNUMBER + 
+       logMetacat.fatal("The maximum of " +MAXIMUMCONNECTIONNUMBER + 
                             " open db connections is reached." +
                             " New db connection to MetaCat" +
-                            " cannot be established.", 1);
+                            " cannot be established.");
        countOfReachMaximum ++;
        if (countOfReachMaximum >= 10)
        {
          countOfReachMaximum =0;
-         MetaCatUtil.debugMessage("finally could not get dbconnection", 1);
+         logMetacat.fatal("finally could not get dbconnection");
          return null;
        }
        else
@@ -306,11 +309,12 @@
          //if couldn't get a connection, sleep 20 seconds and try again.
          try
          {
-           MetaCatUtil.debugMessage("sleep for could not get dbconnection", 20);
+           logMetacat.info("sleep for could not get dbconnection");
            Thread.sleep(5000);
          }
          catch (Exception e)
         {
+           logMetacat.error("Exception in getDBConnection" + e.getMessage());
         }
       }
          
@@ -341,8 +345,8 @@
     //Check if the DBConnection usageCount if it is too many
     if (dbConn.getUsageCount() >= MAXIMUMUSAGENUMBER )
     {
-      MetaCatUtil.debugMessage("Connection usageCount is too many: "+
-      dbConn.getUsageCount(), 65);
+      logMetacat.debug("Connection usageCount is too many: "+
+      dbConn.getUsageCount());
       return false;
     }
     
@@ -349,8 +353,8 @@
     //Check if the DBConnection has too much connection time
     if (dbConn.getConnectionTime() >= MAXIMUMCONNECTIONTIME)
     {
-      MetaCatUtil.debugMessage("Connection has too much connection time: "+
-      dbConn.getConnectionTime(), 65);
+      logMetacat.debug("Connection has too much connection time: "+
+      dbConn.getConnectionTime());
       return false;
     }
     
@@ -357,7 +361,7 @@
     //Check if the DBConnection is too old
     if (dbConn.getAge() >=MAXIMUMAGE)
     {
-      MetaCatUtil.debugMessage("Connection is too old: "+dbConn.getAge(), 65);
+      logMetacat.debug("Connection is too old: "+dbConn.getAge());
       return false;
     }
     
@@ -375,8 +379,8 @@
     }
     catch (Exception e)
     {
-      MetaCatUtil.debugMessage("Error in validateDBConnection: "
-                                +e.getMessage(), 30);
+      logMetacat.error("Error in validateDBConnection: "
+                                +e.getMessage());
       return false;
     }
     
@@ -397,9 +401,9 @@
     index = getIndexOfPoolForConnection(conn);
     if ( index ==-1 )
     {
-      MetaCatUtil.debugMessage("Couldn't find a DBConnection in the pool"
+      logMetacat.info("Couldn't find a DBConnection in the pool"
                                   +" which have same tag to the returned"
-                                  +" DBConnetion object", 30);
+                                  +" DBConnetion object");
       return;
                                   
     }//if
@@ -409,9 +413,9 @@
       //if it is as same as the object's checkoutserial number.
       //if it is same return it. If it is not same, maybe the connection already
       // was returned ealier.
-      MetaCatUtil.debugMessage("serial number in Connection: "
-                                      +conn.getCheckOutSerialNumber(), 65);
-      MetaCatUtil.debugMessage("serial number in local: "+serialNumber, 65);
+      logMetacat.debug("serial number in Connection: "
+                                      +conn.getCheckOutSerialNumber());
+      logMetacat.debug("serial number in local: "+serialNumber);
       if (conn.getCheckOutSerialNumber() == serialNumber)
       {
         dbConn = (DBConnection) connectionPool.elementAt(index);
@@ -424,15 +428,14 @@
         //set check out time to 0
         dbConn.setCheckOutTime(0);
         
-        MetaCatUtil.debugMessage("Connection: "+dbConn.getTag()+" checked in.",
-                                                                        65);
-        MetaCatUtil.debugMessage("Connection: "+dbConn.getTag()+"'s status: "
-                                                    +dbConn.getStatus(), 65);
+        logMetacat.debug("Connection: "+dbConn.getTag()+" checked in.");
+        logMetacat.debug("Connection: "+dbConn.getTag()+"'s status: "
+                                                    +dbConn.getStatus());
                                                                        
       }//if
       else
       {
-        MetaCatUtil.debugMessage("This DBConnection couldn't return", 30);
+        logMetacat.info("This DBConnection couldn't return");
       }//else
     }//else
    
@@ -498,8 +501,8 @@
         }//try
         catch (SQLException e)
         {
-          MetaCatUtil.debugMessage("Error in release connection: "
-                                            +e.getMessage(), 10);
+          logMetacat.error("Error in release connection: "
+                                            +e.getMessage());
         }//catch
       }//for
     }//synchronized
@@ -526,12 +529,12 @@
           if (dbConn.getStatus()==BUSY && 
             (System.currentTimeMillis()-dbConn.getCheckOutTime())>=30000)
           {
-            MetaCatUtil.debugMessage("This DBConnection is checked out for: "
+            logMetacat.fatal("This DBConnection is checked out for: "
             +(System.currentTimeMillis()-dbConn.getCheckOutTime())/1000
-            +" secs" , 1);
-            MetaCatUtil.debugMessage(dbConn.getTag(), 1);
-            MetaCatUtil.debugMessage("method: "
-                                          +dbConn.getCheckOutMethodName(), 10);
+            +" secs");
+            logMetacat.fatal(dbConn.getTag());
+            logMetacat.error("method: "
+                                          +dbConn.getCheckOutMethodName());
             
           }
           
@@ -543,13 +546,13 @@
               //try to print out the warning message for every connection
               if (dbConn.getWarningMessage()!=null)
               {
-                MetaCatUtil.debugMessage("Warning for connection "
-                  +dbConn.getTag()+" : "+ dbConn.getWarningMessage(), 10);
+                logMetacat.warn("Warning for connection "
+                  +dbConn.getTag()+" : "+ dbConn.getWarningMessage());
               }
               //check if it is valiate, if not create new one and replace old one
               if (!validateDBConnection(dbConn))
               {
-                MetaCatUtil.debugMessage("Recyle it: "+ dbConn.getTag(), 65);
+                logMetacat.debug("Recyle it: "+ dbConn.getTag());
                 //close this DBConnection
                 dbConn.close();
                 //remove it form connection pool
@@ -561,8 +564,8 @@
             }//try
             catch (SQLException e)
             {
-              MetaCatUtil.debugMessage("Error in DBConnectionPool.run: "
-                                              +e.getMessage(), 20);
+              logMetacat.error("Error in DBConnectionPool.run: "
+                                              +e.getMessage());
             }//catch
           }//if
         }//for
@@ -574,8 +577,8 @@
       }
       catch (Exception e)
       {
-        MetaCatUtil.debugMessage("Error in DBConnectionPool.run: "
-                                              +e.getMessage(), 20);
+        logMetacat.error("Error in DBConnectionPool.run: "
+                                              +e.getMessage());
       }
     }//while
   }//run
@@ -623,10 +626,10 @@
       //check the status of db. If it is free, count it
       if (db.getStatus() == BUSY)
       {
-        MetaCatUtil.debugMessage("This method having a busy DBConnection: "
-                                    +db.getCheckOutMethodName(), 30);
-        MetaCatUtil.debugMessage("The busy DBConnection tag is: "
-                                    +db.getTag(), 30);
+        logMetacat.warn("This method having a busy DBConnection: "
+                                    +db.getCheckOutMethodName());
+        logMetacat.warn("The busy DBConnection tag is: "
+                                    +db.getTag());
       }//if
     }//for
   
@@ -648,8 +651,8 @@
      DBConnection conn = null; // the dbconnection
      connectionPoolSize = connectionPool.size();
      freeConnectionSize = getFreeDBConnectionNumber();
-     MetaCatUtil.debugMessage("Connection pool size: " +connectionPoolSize, 3);
-     MetaCatUtil.debugMessage("Free Connection number: "+freeConnectionSize, 3);
+     logMetacat.warn("Connection pool size: " +connectionPoolSize);
+     logMetacat.warn("Free Connection number: "+freeConnectionSize);
      difference = connectionPoolSize - freeConnectionSize;
      
      //If all connections are free and connection pool size greater than 
@@ -673,9 +676,9 @@
          { 
            // set hadException ture
            hasException = true;
-           MetaCatUtil.debugMessage("Couldn't close a DBConnection in " +
+           logMetacat.error("Couldn't close a DBConnection in " +
                             "DBConnectionPool.shrinkDBConnectionPoolSize: " +
-                            e.getMessage(), 30);
+                            e.getMessage());
          }//catch
                                         
         //remove it from pool
@@ -710,8 +713,8 @@
      DBConnection conn = null; // the dbconnection
      connectionPoolSize = connectionPool.size();
      freeConnectionSize = getFreeDBConnectionNumber();
-     MetaCatUtil.debugMessage("Connection pool size: " +connectionPoolSize, 35);
-     MetaCatUtil.debugMessage("Free Connection number: "+freeConnectionSize, 35);
+     logMetacat.warn("Connection pool size: " +connectionPoolSize);
+     logMetacat.warn("Free Connection number: "+freeConnectionSize);
      difference = connectionPoolSize - freeConnectionSize;
      
      //If all connections are free and connection pool size greater than 
@@ -736,9 +739,9 @@
            catch (SQLException e)
            { 
           
-             MetaCatUtil.debugMessage("Couldn't close a DBConnection in " +
+             logMetacat.error("Couldn't close a DBConnection in " +
                             "DBConnectionPool.shrinkDBConnectionPoolSize: " +
-                            e.getMessage(), 30);
+                            e.getMessage());
            }//catch
         
            //remove it from pool
Index: src/edu/ucsb/nceas/metacat/DBConnection.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBConnection.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBConnection.java	(revision 2663)
@@ -31,6 +31,8 @@
 import java.io.*;
 import java.sql.*;
 
+import org.apache.log4j.Logger;
+
 /**
  * A class represent a connection object, it includes connection itself, 
  * index, status, age, createtime, connection time, usageCount, warning message
@@ -57,7 +59,8 @@
   private static String  DBConnectedJDBC=MetaCatUtil.getOption("defaultDB");
   private static String  userName=MetaCatUtil.getOption("user");
   private static String  passWord=MetaCatUtil.getOption("password");
-  
+  private static Logger logMetacat = Logger.getLogger(DBConnection.class);
+
   /**
    * Default constructor of the DBConnection class 
    * 
@@ -344,7 +347,7 @@
      }
      catch (ClassNotFoundException e)
      {
-       MetaCatUtil.debugMessage("Error in DBConnectionPool "+e.getMessage(),30);
+       logMetacat.error("Error in DBConnectionPool "+e.getMessage());
        return null;
      }
      // Connect to the database
Index: src/edu/ucsb/nceas/metacat/AuthSession.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AuthSession.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AuthSession.java	(revision 2663)
@@ -31,6 +31,8 @@
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.log4j.Logger;
+
 /**
  * A Class that implements session tracking for MetaCatServlet users.
  * User's login data are stored in the session object.
@@ -42,6 +44,7 @@
   private HttpSession session = null;
   private AuthInterface authService = null;
   private String statusMessage = null;
+  private static Logger logMetacat = Logger.getLogger(AuthSession.class);
 
   /**
    * Construct an AuthSession
@@ -122,13 +125,13 @@
 
     // if it is still in use invalidate and get a new one
     if ( !session.isNew() ) {
-      MetaCatUtil.logMetacat.info("in session is not new");
-      MetaCatUtil.logMetacat.info("the old session id is : " +
+      logMetacat.info("in session is not new");
+      logMetacat.info("the old session id is : " +
                                 session.getId());
-      MetaCatUtil.logMetacat.info("the old session username : " +
+      logMetacat.info("the old session username : " +
                                 session.getAttribute("username"));
       session.invalidate();
-      MetaCatUtil.logMetacat.info("in session is not new");
+      logMetacat.info("in session is not new");
       session = request.getSession(true);
     }
     // store the username, password, and groupname (the first only)
@@ -139,9 +142,9 @@
     if ( groups.length > 0 ) {
       session.setAttribute("groupnames", groups);
     }
-     MetaCatUtil.logMetacat.info("the new session id is : " +
+     logMetacat.info("the new session id is : " +
                                 session.getId());
-     MetaCatUtil.logMetacat.info("the new session username : " +
+     logMetacat.info("the new session username : " +
                                 session.getAttribute("username"));
     return session;
   }
Index: src/edu/ucsb/nceas/metacat/DBQuery.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 2663)
@@ -54,6 +54,7 @@
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.log4j.Logger;
 
 import edu.ucsb.nceas.morpho.datapackage.Triple;
 import edu.ucsb.nceas.morpho.datapackage.TripleCollection;
@@ -78,6 +79,8 @@
 
     private MetaCatUtil util = new MetaCatUtil();
 
+    private Logger logMetacat = Logger.getLogger(DBQuery.class);
+
     /**
      * the main routine used to test the DBQuery utility.
      * <p>
@@ -230,9 +233,9 @@
       // get query and qformat
       String xmlquery = ((String[])params.get("query"))[0];
 
-      MetaCatUtil.debugMessage("xmlquery: " + xmlquery, 30);
+      logMetacat.warn("xmlquery: " + xmlquery);
       String qformat = ((String[])params.get("qformat"))[0];
-      MetaCatUtil.debugMessage("qformat: " + qformat, 30);
+      logMetacat.warn("qformat: " + qformat);
       // Get the XML query and covert it into a SQL statment
       QuerySpecification qspec = null;
       if ( xmlquery != null)
@@ -246,9 +249,9 @@
          }
          catch (Exception ee)
          {
-           MetaCatUtil.debugMessage("erro to generate QuerySpecification object"
+           logMetacat.error("erro to generate QuerySpecification object"
                                     +" in DBQuery.findDocuments"
-                                    + ee.getMessage(), 30);
+                                    + ee.getMessage());
          }
       }
 
@@ -288,8 +291,8 @@
         }
         catch(Exception e)
         {
-         MetaCatUtil.debugMessage("Error in MetaCatServlet.transformResultset:"
-                                +e.getMessage(), 30);
+         logMetacat.error("Error in MetaCatServlet.transformResultset:"
+                                +e.getMessage());
          }
 
       }//else
@@ -336,19 +339,19 @@
       } //try
       catch (IOException ioe)
       {
-        MetaCatUtil.debugMessage("IO error in DBQuery.findDocuments:", 30);
-        MetaCatUtil.debugMessage(ioe.getMessage(), 30);
+        logMetacat.error("IO error in DBQuery.findDocuments:");
+        logMetacat.error(ioe.getMessage());
 
       }
       catch (SQLException e)
       {
-        MetaCatUtil.debugMessage("SQL Error in DBQuery.findDocuments: "
-                                 + e.getMessage(), 30);
+        logMetacat.error("SQL Error in DBQuery.findDocuments: "
+                                 + e.getMessage());
       }
       catch (Exception ee)
       {
-        MetaCatUtil.debugMessage("Exception in DBQuery.findDocuments: "
-                                 + ee.getMessage(), 30);
+        logMetacat.error("Exception in DBQuery.findDocuments: "
+                                 + ee.getMessage());
       }
       finally
       {
@@ -404,8 +407,8 @@
       int rev = 0;
       String query = qspec.printSQL(useXMLIndex);
       String ownerQuery = getOwnerQuery(user);
-      MetaCatUtil.debugMessage("query: " + query, 30);
-      //MetaCatUtil.debugMessage("query: "+ownerQuery, 30);
+      logMetacat.info("query: " + query);
+      //logMetacat.info("query: "+ownerQuery);
       // if query is not the owner query, we need to check the permission
       // otherwise we don't need (owner has all permission by default)
       if (!query.equals(ownerQuery))
@@ -420,7 +423,7 @@
         } else {
             query = query + accessQuery.substring(4, accessQuery.length());
         }
-        MetaCatUtil.debugMessage(" final query: " + query, 30);
+        logMetacat.warn(" final query: " + query);
       }
 
       double startTime = System.currentTimeMillis() / 1000;
@@ -430,8 +433,8 @@
       pstmt.execute();
       ResultSet rs = pstmt.getResultSet();
       double queryExecuteTime = System.currentTimeMillis() / 1000;
-      MetaCatUtil.debugMessage("Time for execute query: "
-                    + (queryExecuteTime - startTime), 30);
+      logMetacat.warn("Time for execute query: "
+                    + (queryExecuteTime - startTime));
       boolean tableHasRows = rs.next();
       while (tableHasRows)
       {
@@ -448,7 +451,7 @@
          if (returndocVec.size() != 0 && !returndocVec.contains(doctype)
                         && !qspec.isPercentageSearch())
         {
-           MetaCatUtil.debugMessage("Back tracing now...", 20);
+           logMetacat.warn("Back tracing now...");
            String sep = MetaCatUtil.getOption("accNumSeparator");
            StringBuffer btBuf = new StringBuffer();
            btBuf.append("select docid from xml_relation where ");
@@ -480,8 +483,8 @@
                //there was a backtrackable document found
                DocumentImpl xmldoc = null;
                String packageDocid = btrs.getString(1);
-               MetaCatUtil.debugMessage("Getting document for docid: "
-                                         + packageDocid, 40);
+               logMetacat.info("Getting document for docid: "
+                                         + packageDocid);
                 try
                 {
                     //  THIS CONSTRUCTOR BUILDS THE WHOLE XML doc not
@@ -494,8 +497,8 @@
                     xmldoc = new DocumentImpl(accNumber, false);
                     if (xmldoc == null)
                     {
-                       MetaCatUtil.debugMessage("Document was null for: "
-                                                + packageDocid, 50);
+                       logMetacat.info("Document was null for: "
+                                                + packageDocid);
                     }
                 }
                 catch (Exception e)
@@ -508,7 +511,7 @@
                 String docid_org = xmldoc.getDocID();
                 if (docid_org == null)
                 {
-                   MetaCatUtil.debugMessage("Docid_org was null.", 40);
+                   logMetacat.info("Docid_org was null.");
                    //continue;
                 }
                 docid = docid_org.trim();
@@ -606,8 +609,8 @@
                               user, groups,dbconn, useXMLIndex);
      }
      double docListTime = System.currentTimeMillis() / 1000;
-     MetaCatUtil.debugMessage("prepare docid list time: "
-                    + (docListTime - queryExecuteTime), 30);
+     logMetacat.warn("prepare docid list time: "
+                    + (docListTime - queryExecuteTime));
 
      return resultsetBuffer;
     }//findReturnDoclist
@@ -642,16 +645,16 @@
      }
 
      if(returnfield_id < 0){
-         MetaCatUtil.debugMessage("Error in getting returnfield id from"
-                                  + "xml_returnfield table", 20);
+         logMetacat.warn("Error in getting returnfield id from"
+                                  + "xml_returnfield table");
 	enterRecords = false;
      }
 
      // get the hashtable containing the docids that already in the
      // xml_queryresult table
-     MetaCatUtil.debugMessage("size of partOfDoclist before"
+     logMetacat.info("size of partOfDoclist before"
                              + " docidsInQueryresultTable(): "
-                             + partOfDoclist.size() , 50);
+                             + partOfDoclist.size());
      Hashtable queryresultDocList = docidsInQueryresultTable(returnfield_id,
                                                         partOfDoclist, dbconn);
 
@@ -670,9 +673,9 @@
          partOfDoclistBackup.put(key, partOfDoclist.get(key));
      }
 
-     MetaCatUtil.debugMessage("size of partOfDoclist after"
+     logMetacat.info("size of partOfDoclist after"
                              + " docidsInQueryresultTable(): "
-                             + partOfDoclist.size() , 50);
+                             + partOfDoclist.size());
 
      //add return fields for the documents in partOfDoclist
      partOfDoclist = addReturnfield(partOfDoclist, qspec, user, groups,
@@ -774,8 +777,8 @@
              String query = "select docid, queryresult_string from "
                           + "xml_queryresult where returnfield_id = " +
                           returnfield_id +" and docid in ("+ doclist + ")";
-             MetaCatUtil.debugMessage("Query to get docids from xml_queryresult:"
-                                      + query, 50);
+             logMetacat.info("Query to get docids from xml_queryresult:"
+                                      + query);
 
              try {
                  // prepare and execute the query
@@ -792,8 +795,8 @@
                      if(element != null){
                          returnValue.put(key, element);
                      } else {
-                         MetaCatUtil.debugMessage("Null elment found ("
-                         + "DBQuery.docidsInQueryresultTable)", 50);
+                         logMetacat.info("Null elment found ("
+                         + "DBQuery.docidsInQueryresultTable)");
                      }
                      tableHasRows = rs.next();
                  }
@@ -800,10 +803,10 @@
                  rs.close();
                  pstmt.close();
              } catch (Exception e){
-                 MetaCatUtil.debugMessage("Error getting docids from "
+                 logMetacat.error("Error getting docids from "
                                           + "queryresult in "
                                           + "DBQuery.docidsInQueryresultTable: "
-                                          + e.getMessage(), 20);
+                                          + e.getMessage());
               }
          }
          return returnValue;
@@ -826,7 +829,7 @@
        // query for finding the id from xml_returnfield
        String query = "SELECT returnfield_id, usage_count FROM xml_returnfield "
             + "WHERE returnfield_string LIKE ?";
-       MetaCatUtil.debugMessage("ReturnField Query:" + query, 50);
+       logMetacat.info("ReturnField Query:" + query);
 
        try {
            // prepare and run the query
@@ -849,7 +852,7 @@
                // increase the usage count
                query = "UPDATE xml_returnfield SET usage_count ='" + count
                    + "' WHERE returnfield_id ='"+ id +"'";
-               MetaCatUtil.debugMessage("ReturnField Table Update:"+ query, 50);
+               logMetacat.info("ReturnField Table Update:"+ query);
 
                pstmt = dbconn.prepareStatement(query);
                dbconn.increaseUsageCount(1);
@@ -863,7 +866,7 @@
                // insert a new record
                query = "INSERT INTO xml_returnfield (returnfield_string, usage_count)"
                    + "VALUES (?, '1')";
-               MetaCatUtil.debugMessage("ReturnField Table Insert:"+ query, 50);
+               logMetacat.info("ReturnField Table Insert:"+ query);
                pstmt = dbconn.prepareStatement(query);
                pstmt.setString(1, returnfield);
                dbconn.increaseUsageCount(1);
@@ -873,7 +876,7 @@
                // get the id of the new record
                query = "SELECT returnfield_id FROM xml_returnfield "
                    + "WHERE returnfield_string LIKE ?";
-               MetaCatUtil.debugMessage("ReturnField query after Insert:" + query, 50);
+               logMetacat.info("ReturnField query after Insert:" + query);
                pstmt = dbconn.prepareStatement(query);
                pstmt.setString(1, returnfield);
 
@@ -890,9 +893,9 @@
            }
 
        } catch (Exception e){
-           MetaCatUtil.debugMessage("Error getting id from xml_returnfield in "
+           logMetacat.error("Error getting id from xml_returnfield in "
                                      + "DBQuery.getXmlReturnfieldsTableId: "
-                                     + e.getMessage(), 20);
+                                     + e.getMessage());
            id = -1;
        }
 
@@ -956,12 +959,12 @@
           }
 
            double extendedAccessQueryEnd = System.currentTimeMillis() / 1000;
-           MetaCatUtil.debugMessage( "Time for execute access extended query: "
-                          + (extendedAccessQueryEnd - extendedQueryStart),30);
+           logMetacat.info( "Time for execute access extended query: "
+                          + (extendedAccessQueryEnd - extendedQueryStart));
 
            String extendedQuery =
                qspec.printExtendedSQL(doclist.toString(), controlPairs, useXMLIndex);
-           MetaCatUtil.debugMessage("Extended query: " + extendedQuery, 30);
+           logMetacat.warn("Extended query: " + extendedQuery);
 
            if(extendedQuery != null){
                pstmt = dbconn.prepareStatement(extendedQuery);
@@ -970,9 +973,9 @@
                pstmt.execute();
                rs = pstmt.getResultSet();
                double extendedQueryEnd = System.currentTimeMillis() / 1000;
-               MetaCatUtil.debugMessage(
+               logMetacat.info(
                    "Time for execute extended query: "
-                   + (extendedQueryEnd - extendedQueryStart), 30);
+                   + (extendedQueryEnd - extendedQueryStart));
                tableHasRows = rs.next();
                while (tableHasRows) {
                    ReturnFieldValue returnValue = new ReturnFieldValue();
@@ -1043,11 +1046,10 @@
                    }
                } //while
                double docListResultEnd = System.currentTimeMillis() / 1000;
-               MetaCatUtil.debugMessage(
+               logMetacat.warn(
                    "Time for prepare doclistresult after"
                    + " execute extended query: "
-                   + (docListResultEnd - extendedQueryEnd),
-                   30);
+                   + (docListResultEnd - extendedQueryEnd));
            }
 
            // get attribures return
@@ -1120,8 +1122,8 @@
       pstmt.close();
     }//while
     double endRelation = System.currentTimeMillis() / 1000;
-    MetaCatUtil.debugMessage("Time for adding relation to docListResult: "
-                             + (endRelation - startRelation), 30);
+    logMetacat.info("Time for adding relation to docListResult: "
+                             + (endRelation - startRelation));
 
     return docListResult;
   }//addRelation
@@ -1279,17 +1281,17 @@
                 rs.close();
                 pstmt.close();
             } catch (Exception se) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DBQuery.getAttributeValue1: "
-                                + se.getMessage(), 30);
+                                + se.getMessage());
             } finally {
                 try {
                     pstmt.close();
                 }//try
                 catch (SQLException sqlE) {
-                    MetaCatUtil.debugMessage(
+                    logMetacat.error(
                             "Error in DBQuery.getAttributeValue2: "
-                                    + sqlE.getMessage(), 30);
+                                    + sqlE.getMessage());
                 }//catch
                 finally {
                     DBConnectionPool.returnDBConnection(dbconn, serialNumber);
@@ -1607,8 +1609,8 @@
             pStmt.close();
         }//try
         catch (SQLException e) {
-            MetaCatUtil.debugMessage("Error in getDocidListForDataPackage: "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in getDocidListForDataPackage: "
+                    + e.getMessage());
         }//catch
         finally {
             try {
@@ -1615,9 +1617,9 @@
                 pStmt.close();
             }//try
             catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in getDocidListForDataPackage: "
-                                + ee.getMessage(), 30);
+                                + ee.getMessage());
             }//catch
             finally {
                 DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1668,8 +1670,8 @@
             }//for
         }//try
         catch (Exception e) {
-            MetaCatUtil.debugMessage("Error in getOldVersionAllDocumentImpl: "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in getOldVersionAllDocumentImpl: "
+                    + e.getMessage());
         }//catch
 
         // return result
@@ -1711,15 +1713,15 @@
             pStmt.close();
         }//try
         catch (SQLException e) {
-            MetaCatUtil.debugMessage("Error in isDataPackageId: "
-                    + e.getMessage(), 30);
+            logMetacat.error("Error in isDataPackageId: "
+                    + e.getMessage());
         } finally {
             try {
                 pStmt.close();
             }//try
             catch (SQLException ee) {
-                MetaCatUtil.debugMessage("Error in isDataPackageId: "
-                        + ee.getMessage(), 30);
+                logMetacat.error("Error in isDataPackageId: "
+                        + ee.getMessage());
             }//catch
             finally {
                 DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1779,9 +1781,9 @@
 
         }//try
         catch (SQLException e) {
-            MetaCatUtil.debugMessage(
+            logMetacat.error(
                     "Error in getCurrentRevFromXMLDoumentsTable: "
-                            + e.getMessage(), 30);
+                            + e.getMessage());
             throw e;
         }//catch
         finally {
@@ -1789,9 +1791,9 @@
                 pStmt.close();
             }//try
             catch (SQLException ee) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in getCurrentRevFromXMLDoumentsTable: "
-                                + ee.getMessage(), 30);
+                                + ee.getMessage());
             }//catch
             finally {
                 DBConnectionPool.returnDBConnection(dbConn, serialNumber);
@@ -1874,8 +1876,8 @@
                 documentImplList.add(documentImplObject);
             }//try
             catch (Exception e) {
-                MetaCatUtil.debugMessage("Error in getCurrentAllDocumentImpl: "
-                        + e.getMessage(), 30);
+                logMetacat.error("Error in getCurrentAllDocumentImpl: "
+                        + e.getMessage());
                 // continue the for loop
                 continue;
             }
@@ -1915,9 +1917,9 @@
                 documentImplList.add(documentImplObject);
             }//try
             catch (McdbDocNotFoundException notFoundE) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DBQuery.getOldVersionAllDocument" + "Imple"
-                                + notFoundE.getMessage(), 30);
+                                + notFoundE.getMessage());
                 // Rather than add a DocumentImple object into vetor, a String
                 // object
                 // - the doicd was added to the vector
@@ -1926,9 +1928,9 @@
                 continue;
             }//catch
             catch (Exception e) {
-                MetaCatUtil.debugMessage(
+                logMetacat.error(
                         "Error in DBQuery.getOldVersionAllDocument" + "Imple"
-                                + e.getMessage(), 30);
+                                + e.getMessage());
                 // Continue the for loop
                 continue;
             }//catch
@@ -1972,8 +1974,8 @@
             zipOut.closeEntry();
         }//try
         catch (IOException ioe) {
-            MetaCatUtil.debugMessage("There is an exception: "
-                    + ioe.getMessage(), 30);
+            logMetacat.error("There is an exception: "
+                    + ioe.getMessage());
         }//catch
     }//addDataFileToZipOutputStream()
 
@@ -2181,17 +2183,17 @@
                         .equals("class java.lang.String")) {
                     // Get String object from vetor
                     String documentId = (String) documentImplList.elementAt(i);
-                    MetaCatUtil.debugMessage("docid: " + documentId, 30);
+                    logMetacat.info("docid: " + documentId);
                     // Get doicd without revision
                     String docidWithoutRevision = MetaCatUtil
                             .getDocIdFromString(documentId);
-                    MetaCatUtil.debugMessage("docidWithoutRevsion: "
-                            + docidWithoutRevision, 30);
+                    logMetacat.info("docidWithoutRevsion: "
+                            + docidWithoutRevision);
                     // Get revision
                     String revision = MetaCatUtil
                             .getRevisionStringFromString(documentId);
-                    MetaCatUtil.debugMessage("revsion from docIdentifier: "
-                            + revision, 30);
+                    logMetacat.info("revsion from docIdentifier: "
+                            + revision);
                     // Zip entry string
                     String zipEntryPath = rootName + "/data/";
                     // Create a RemoteDocument object
Index: src/edu/ucsb/nceas/metacat/AccessControlForSingleFile.java
===================================================================
--- src/edu/ucsb/nceas/metacat/AccessControlForSingleFile.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/AccessControlForSingleFile.java	(revision 2663)
@@ -35,6 +35,7 @@
 import java.util.Hashtable;
 import java.net.URL;
 import java.net.MalformedURLException;
+import org.apache.log4j.Logger;
 
 
 /** 
@@ -52,8 +53,8 @@
   private int    permission;
   private String permType;
   private String permOrder;
+  private Logger logMetacat = Logger.getLogger(AccessControlForSingleFile.class);
 
-
  
   /**
    * Construct an instance of the AccessControlForSingleFile class.
@@ -109,20 +110,20 @@
         permOrder = AccessControlInterface.ALLOWFIRST;
       }
       //debugMessage
-      MetaCatUtil.logMetacat.info("docid in AccessControlForSingleFiel: " +
+      logMetacat.info("docid in AccessControlForSingleFiel: " +
                                 docId);
-      MetaCatUtil.logMetacat.info("principal in AccessControlForSingleFiel: " +
+      logMetacat.info("principal in AccessControlForSingleFiel: " +
                                 principal);
-      MetaCatUtil.logMetacat.info("permission in AccessControlForSingleFiel: " +
+      logMetacat.info("permission in AccessControlForSingleFiel: " +
                                 permission);
-      MetaCatUtil.logMetacat.info("permType in AccessControlForSingleFiel: " +
+      logMetacat.info("permType in AccessControlForSingleFiel: " +
                                 permType);
-      MetaCatUtil.logMetacat.info("permOrder in AccessControlForSingleFiel: " +
+      logMetacat.info("permOrder in AccessControlForSingleFiel: " +
                                 permOrder);
     }
     catch (Exception e)
     {
-      MetaCatUtil.logMetacat.info("Error in construct of AccessControlForSingle" +
+      logMetacat.error("Error in construct of AccessControlForSingle" +
                                "File: " + e.getMessage());
       throw e;
     }
@@ -165,7 +166,7 @@
     }//try
     catch (SQLException e)
     {
-      MetaCatUtil.logMetacat.info("Error in AccessControlForSingleFile.insert" +
+      logMetacat.error("Error in AccessControlForSingleFile.insert" +
                                "Permissions: " + e.getMessage());
       throw e;
     }
Index: src/edu/ucsb/nceas/metacat/DBTransform.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBTransform.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBTransform.java	(revision 2663)
@@ -43,6 +43,7 @@
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerConfigurationException;
 
+import org.apache.log4j.Logger;
 import org.apache.xerces.parsers.DOMParser;
 import org.w3c.dom.Attr;
 import org.w3c.dom.NamedNodeMap;
@@ -79,7 +80,8 @@
   private MetaCatUtil   util = null;
   private String 	configDir = null;
   private String	defaultStyle = null;
-
+  private Logger logMetacat = Logger.getLogger(DBTransform.class);
+  
   /**
    * construct a DBTransform instance.
    *
@@ -194,9 +196,9 @@
       }
       catch (Exception e)
       {
-        util.debugMessage(xslSystemId + "Error transforming document in " +
+        logMetacat.error(xslSystemId + "Error transforming document in " +
                    "DBTransform.transformXMLDocument: " +
-                   e.getMessage(), 30);
+                   e.getMessage());
 
       }
     }
@@ -262,7 +264,7 @@
         Transformer transformer = tFactory.newTransformer(
                                   new StreamSource(xslSystemId));
         transformer.setParameter("qformat", qformat);
-        MetaCatUtil.debugMessage("qformat: "+qformat, 30);
+        logMetacat.warn("qformat: "+qformat);
 
         if(sessionid != null)
         {
@@ -276,7 +278,7 @@
           {
             String key =(String)en.nextElement();
             String value = ((String[])(param.get(key)))[0];
-            MetaCatUtil.debugMessage(key+" : "+value, 30);
+            logMetacat.warn(key+" : "+value);
             transformer.setParameter(key, value);
           }
         }
@@ -359,7 +361,7 @@
     try {
       boolean breakflag = false;
       String filename = configDir + "/" + qformat + "/" + qformat + ".xml";
-      util.debugMessage("Trying style-set file: " + filename, 30);
+      logMetacat.warn("Trying style-set file: " + filename);
       File f = new File(filename);
       NodeList nlDoctype = getPathContent(f, "/style-set/doctype");
       NodeList nlDefault = getPathContent(f, "/style-set/default-style");
@@ -420,7 +422,7 @@
     }
 
     // Return the system ID for this particular source document type
-    MetaCatUtil.debugMessage("style system id is: "+systemId, 30);
+    logMetacat.info("style system id is: "+systemId);
     return systemId;
   }
 
@@ -435,11 +437,11 @@
     {
       return;
     }
-    MetaCatUtil.debugMessage("public id of input stream is " +publicId, 25);
+    logMetacat.info("public id of input stream is " +publicId);
     // Get system id from xml_catalog table
     String systemId = DBEntityResolver.getDTDSystemID(publicId);
-    MetaCatUtil.debugMessage("system id of input stream from xml_catalog"
-                               +"table is " +systemId, 25);
+    logMetacat.info("system id of input stream from xml_catalog"
+                               +"table is " +systemId);
     //set system id to input stream
     xml.setSystemId(systemId);
   }
Index: src/edu/ucsb/nceas/metacat/DBEntityResolver.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBEntityResolver.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/DBEntityResolver.java	(revision 2663)
@@ -28,6 +28,7 @@
 
 package edu.ucsb.nceas.metacat;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.*;
 import org.xml.sax.helpers.DefaultHandler;
 
@@ -58,7 +59,8 @@
   private String doctype = null;
   private String systemid = null;
   private Reader dtdtext = null;
-
+  private static Logger logMetacat = Logger.getLogger(DBEntityResolver.class);
+  
   /**
    * Construct an instance of the DBEntityResolver class
    *
@@ -91,7 +93,7 @@
   public InputSource resolveEntity (String publicId, String systemId)
                      throws SAXException
   {
-    MetaCatUtil.debugMessage("in DBEntityResolver.resolveEntity", 60);
+    logMetacat.debug("in DBEntityResolver.resolveEntity");
     String dbSystemID;
     String doctype = null;
 
@@ -105,8 +107,8 @@
           // public ID is doctype
           if (publicId != null) {
             doctype = publicId;
-            MetaCatUtil.debugMessage("in get type from publicId and doctype is: "
-                                     +doctype, 50);
+            logMetacat.info("in get type from publicId and doctype is: "
+                                     +doctype);
           // assume public ID (doctype) is docname
           } else if (systemId != null) {
             doctype = dhandler.getDocname();
@@ -130,9 +132,9 @@
     // get System ID for doctype
     if (doctype != null) {
       // look at db XML Catalog for System ID
-      MetaCatUtil.debugMessage("get systemId from doctype: "+doctype, 35);
+      logMetacat.info("get systemId from doctype: "+doctype);
       dbSystemID = getDTDSystemID(doctype);
-      MetaCatUtil.debugMessage("The Systemid is: "+dbSystemID, 35);
+      logMetacat.info("The Systemid is: "+dbSystemID);
       boolean doctypeIsInDB = true;
       // no System ID found in db XML Catalog
       if (dbSystemID == null) {
@@ -141,8 +143,8 @@
         if (systemId != null) {
           dbSystemID = systemId;
         }
-        MetaCatUtil.debugMessage("If above Systemid is null and then get "
-                                 +" system id from file" + dbSystemID, 35);
+        logMetacat.info("If above Systemid is null and then get "
+                                 +" system id from file" + dbSystemID);
       }
       // there are dtd text provided; try to upload on Metacat
       if ( dtdtext != null ) {
@@ -175,7 +177,7 @@
       return is;
     } else {
       // use provided systemId for the other cases
-      MetaCatUtil.debugMessage("doctype is null and using system id from file", 50);
+      logMetacat.info("doctype is null and using system id from file");
       InputStream istream = checkURLConnection(systemId);
       return null;
 
@@ -221,8 +223,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in DBEntityReolver.getDTDSystemId: "
-                                  +sqlE.getMessage(), 30);
+        logMetacat.error("Error in DBEntityReolver.getDTDSystemId: "
+                                  +sqlE.getMessage());
       }//catch
       finally
       {
@@ -275,8 +277,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in DBEntityReolver.registerDTD: "
-                                    +sqlE.getMessage(), 30);
+        logMetacat.error("Error in DBEntityReolver.registerDTD: "
+                                    +sqlE.getMessage());
       }//catch
       //DBConnectionPool.returnDBConnection(conn, serialNumber);
     }//finally
Index: src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/Eml210SAXHandler.java	(revision 2663)
@@ -44,6 +44,7 @@
 import java.util.Stack;
 import java.util.Vector;
 
+import org.apache.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
@@ -166,6 +167,8 @@
 
     private static final String RELATION = "Provides info for";
 
+    private Logger logMetacat = Logger.getLogger(Eml210SAXHandler.class);   	   	
+
     /**
      * Construct an instance of the handler class In this constructor, user can
      * specify the version need to upadate
@@ -225,14 +228,14 @@
                 // Get a subtree without node record list
                 SubTree treeWithoutStack = (SubTree) en.nextElement();
                 String subTreeId = treeWithoutStack.getSubTreeId();
-                MetaCatUtil.debugMessage(
-                        "unchangable subtree id: " + subTreeId, 40);
+                logMetacat.info(
+                        "unchangable subtree id: " + subTreeId);
                 long startNodeId = treeWithoutStack.getStartNodeId();
-                MetaCatUtil.debugMessage("unchangable subtree startnodeid: "
-                        + startNodeId, 40);
+                logMetacat.info("unchangable subtree startnodeid: "
+                        + startNodeId);
                 long endNodeId = treeWithoutStack.getEndNodeId();
-                MetaCatUtil.debugMessage("unchangable subtree endnodeid: "
-                        + endNodeId, 40);
+                logMetacat.info("unchangable subtree endnodeid: "
+                        + endNodeId);
                 // Get a subtree has the nodelist
                 SubTree tree = new SubTree(docid, subTreeId, startNodeId,
                         endNodeId);
@@ -316,9 +319,9 @@
         // for element <eml:eml...> qname is "eml:eml", local name is "eml"
         // for element <acl....> both qname and local name is "eml"
         // uri is namesapce
-        MetaCatUtil.debugMessage("Start ELEMENT(qName) " + qName, 50);
-        MetaCatUtil.debugMessage("Start ELEMENT(localName) " + localName, 50);
-        MetaCatUtil.debugMessage("Start ELEMENT(uri) " + uri, 50);
+        logMetacat.info("Start ELEMENT(qName) " + qName);
+        logMetacat.info("Start ELEMENT(localName) " + localName);
+        logMetacat.info("Start ELEMENT(uri) " + uri);
 
         DBSAXNode parentNode = null;
         DBSAXNode currentNode = null;
@@ -402,13 +405,13 @@
                     } else {
                         doctype = docname;
                     }
-                    MetaCatUtil.debugMessage("DOCNAME-a: " + docname, 30);
-                    MetaCatUtil.debugMessage("DOCTYPE-a: " + doctype, 30);
+                    logMetacat.info("DOCNAME-a: " + docname);
+                    logMetacat.info("DOCTYPE-a: " + doctype);
                 } else if (doctype == null) {
                     // because docname is not null and it is declared in dtd
                     // so could not be in schema, no namespace
                     doctype = docname;
-                    MetaCatUtil.debugMessage("DOCTYPE-b: " + doctype, 30);
+                    logMetacat.info("DOCTYPE-b: " + doctype);
                 }
                 rootNode.writeNodename(docname);
                 try {
@@ -683,8 +686,8 @@
             inlineDataNameSpace = null;
             inlineDataNameSpace = new Hashtable();
             //write inline data into file
-            MetaCatUtil.debugMessage("the inline element data is: "
-                    + inlineElements.toString(), 50);
+            logMetacat.info("the inline element data is: "
+                    + inlineElements.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineElements);
         }//else
 
@@ -699,20 +702,18 @@
         try {
             elementNode = (NodeRecord) unchangableNodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil
-                    .debugMessage("Node stack is empty for element data", 35);
+            logMetacat.error("Node stack is empty for element data");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage("current node type from xml is ELEMENT", 40);
-        MetaCatUtil.debugMessage("node type from stack: "
-                + elementNode.getNodeType(), 40);
-        MetaCatUtil.debugMessage("node name from xml document: " + localName,
-                40);
-        MetaCatUtil.debugMessage("node name from stack: "
-                + elementNode.getNodeName(), 40);
-        MetaCatUtil.debugMessage("node data from stack: "
-                + elementNode.getNodeData(), 40);
-        MetaCatUtil.debugMessage("node id is: " + elementNode.getNodeId(), 40);
+        logMetacat.info("current node type from xml is ELEMENT");
+        logMetacat.info("node type from stack: "
+                + elementNode.getNodeType());
+        logMetacat.info("node name from xml document: " + localName);
+        logMetacat.info("node name from stack: "
+                + elementNode.getNodeName());
+        logMetacat.info("node data from stack: "
+                + elementNode.getNodeData());
+        logMetacat.info("node id is: " + elementNode.getNodeId());
         // if this node is not element or local name not equal or name space
         // not
         // equals, throw an exception
@@ -720,19 +721,17 @@
                 || !localName.equals(elementNode.getNodeName()))
         //  (uri != null && !uri.equals(elementNode.getNodePrefix())))
         {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage("current node type from xml is ELEMENT",
-                    40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + elementNode.getNodeType(), 40);
-            MetaCatUtil.debugMessage("node name from xml document: "
-                    + localName, 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + elementNode.getNodeName(), 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + elementNode.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node id is: " + elementNode.getNodeId(),
-                    40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info("current node type from xml is ELEMENT");
+            logMetacat.info("node type from stack: "
+                    + elementNode.getNodeType());
+            logMetacat.info("node name from xml document: "
+                    + localName);
+            logMetacat.info("node name from stack: "
+                    + elementNode.getNodeName());
+            logMetacat.info("node data from stack: "
+                    + elementNode.getNodeData());
+            logMetacat.info("node id is: " + elementNode.getNodeId());
             throw new SAXException(error);
         }
 
@@ -744,8 +743,8 @@
             try {
                 nameNode = (NodeRecord) unchangableNodeStack.pop();
             } catch (EmptyStackException ee) {
-                MetaCatUtil.debugMessage(
-                        "Node stack is empty for namespace data", 35);
+                logMetacat.error(
+                        "Node stack is empty for namespace data");
                 throw new SAXException(error);
             }
 
@@ -754,21 +753,20 @@
             if (!nameNode.getNodeType().equals("NAMESPACE")
                     || !prefixName.equals(nameNode.getNodeName())
                     || !nameSpaceUri.equals(nameNode.getNodeData())) {
-                MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-                MetaCatUtil.debugMessage(
-                        "current node type from xml is NAMESPACE", 40);
-                MetaCatUtil.debugMessage("node type from stack: "
-                        + nameNode.getNodeType(), 40);
-                MetaCatUtil.debugMessage("current node name from xml is: "
-                        + prefixName, 40);
-                MetaCatUtil.debugMessage("node name from stack: "
-                        + nameNode.getNodeName(), 40);
-                MetaCatUtil.debugMessage("current node data from xml is: "
-                        + nameSpaceUri, 40);
-                MetaCatUtil.debugMessage("node data from stack: "
-                        + nameNode.getNodeData(), 40);
-                MetaCatUtil.debugMessage("node id is: " + nameNode.getNodeId(),
-                        40);
+                logMetacat.info("Inconsistence happend: ");
+                logMetacat.info(
+                        "current node type from xml is NAMESPACE");
+                logMetacat.info("node type from stack: "
+                        + nameNode.getNodeType());
+                logMetacat.info("current node name from xml is: "
+                        + prefixName);
+                logMetacat.info("node name from stack: "
+                        + nameNode.getNodeName());
+                logMetacat.info("current node data from xml is: "
+                        + nameSpaceUri);
+                logMetacat.info("node data from stack: "
+                        + nameNode.getNodeData());
+                logMetacat.info("node id is: " + nameNode.getNodeId());
                 throw new SAXException(error);
             }
 
@@ -781,45 +779,43 @@
                 attriNode = (NodeRecord) unchangableNodeStack.pop();
 
             } catch (EmptyStackException ee) {
-                MetaCatUtil.debugMessage(
-                        "Node stack is empty for attribute data", 35);
+                logMetacat.error(
+                        "Node stack is empty for attribute data");
                 throw new SAXException(error);
             }
             String attributeName = attributes.getQName(i);
             String attributeValue = attributes.getValue(i);
-            MetaCatUtil.debugMessage(
-                    "current node type from xml is ATTRIBUTE ", 40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + attriNode.getNodeType(), 40);
-            MetaCatUtil.debugMessage("current node name from xml is: "
-                    + attributeName, 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + attriNode.getNodeName(), 40);
-            MetaCatUtil.debugMessage("current node data from xml is: "
-                    + attributeValue, 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + attriNode.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node id  is: " + attriNode.getNodeId(),
-                    40);
+            logMetacat.info(
+                    "current node type from xml is ATTRIBUTE ");
+            logMetacat.info("node type from stack: "
+                    + attriNode.getNodeType());
+            logMetacat.info("current node name from xml is: "
+                    + attributeName);
+            logMetacat.info("node name from stack: "
+                    + attriNode.getNodeName());
+            logMetacat.info("current node data from xml is: "
+                    + attributeValue);
+            logMetacat.info("node data from stack: "
+                    + attriNode.getNodeData());
+            logMetacat.info("node id  is: " + attriNode.getNodeId());
 
             if (!attriNode.getNodeType().equals("ATTRIBUTE")
                     || !attributeName.equals(attriNode.getNodeName())
                     || !attributeValue.equals(attriNode.getNodeData())) {
-                MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-                MetaCatUtil.debugMessage(
-                        "current node type from xml is ATTRIBUTE ", 40);
-                MetaCatUtil.debugMessage("node type from stack: "
-                        + attriNode.getNodeType(), 40);
-                MetaCatUtil.debugMessage("current node name from xml is: "
-                        + attributeName, 40);
-                MetaCatUtil.debugMessage("node name from stack: "
-                        + attriNode.getNodeName(), 40);
-                MetaCatUtil.debugMessage("current node data from xml is: "
-                        + attributeValue, 40);
-                MetaCatUtil.debugMessage("node data from stack: "
-                        + attriNode.getNodeData(), 40);
-                MetaCatUtil.debugMessage("node is: " + attriNode.getNodeId(),
-                        40);
+                logMetacat.info("Inconsistence happend: ");
+                logMetacat.info(
+                        "current node type from xml is ATTRIBUTE ");
+                logMetacat.info("node type from stack: "
+                        + attriNode.getNodeType());
+                logMetacat.info("current node name from xml is: "
+                        + attributeName);
+                logMetacat.info("node name from stack: "
+                        + attriNode.getNodeName());
+                logMetacat.info("current node data from xml is: "
+                        + attributeValue);
+                logMetacat.info("node data from stack: "
+                        + attriNode.getNodeData());
+                logMetacat.info("node is: " + attriNode.getNodeId());
                 throw new SAXException(error);
             }
         }//for
@@ -835,35 +831,32 @@
         try {
             node = (NodeRecord) nodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil.debugMessage(
-                    "Node stack is empty for text data in startElement", 35);
+            logMetacat.error(
+                    "Node stack is empty for text data in startElement");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage(
-                "current node type from xml is TEXT in start element", 40);
-        MetaCatUtil.debugMessage("node type from stack: " + node.getNodeType(),
-                40);
-        MetaCatUtil.debugMessage("current node data from xml is: "
-                + text.toString(), 40);
-        MetaCatUtil.debugMessage("node data from stack: " + node.getNodeData(),
-                40);
-        MetaCatUtil.debugMessage("node name from stack: " + node.getNodeName(),
-                40);
-        MetaCatUtil.debugMessage("node is: " + node.getNodeId(), 40);
+        logMetacat.info(
+                "current node type from xml is TEXT in start element");
+        logMetacat.info("node type from stack: " + node.getNodeType());
+        logMetacat.info("current node data from xml is: "
+                + text.toString());
+        logMetacat.info("node data from stack: " + node.getNodeData());
+        logMetacat.info("node name from stack: " + node.getNodeName());
+        logMetacat.info("node is: " + node.getNodeId());
         if (!node.getNodeType().equals("TEXT")
                 || !(text.toString()).equals(node.getNodeData())) {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage(
-                    "current node type from xml is TEXT in start element", 40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + node.getNodeType(), 40);
-            MetaCatUtil.debugMessage("current node data from xml is: "
-                    + text.toString(), 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + node.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node name from stack: "
-                    + node.getNodeName(), 40);
-            MetaCatUtil.debugMessage("node is: " + node.getNodeId(), 40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info(
+                    "current node type from xml is TEXT in start element");
+            logMetacat.info("node type from stack: "
+                    + node.getNodeType());
+            logMetacat.info("current node data from xml is: "
+                    + text.toString());
+            logMetacat.info("node data from stack: "
+                    + node.getNodeData());
+            logMetacat.info("node name from stack: "
+                    + node.getNodeName());
+            logMetacat.info("node is: " + node.getNodeId());
             throw new SAXException(error);
         }//if
     }
@@ -871,7 +864,7 @@
     /** SAX Handler that is called for each XML text node */
     public void characters(char[] cbuf, int start, int len) throws SAXException
     {
-        MetaCatUtil.debugMessage("CHARACTERS", 50);
+        logMetacat.info("CHARACTERS");
         if (!handleInlineData) {
             // buffer all text nodes for same element. This is for text was
             // splited
@@ -882,11 +875,8 @@
             // if text buffer .size is greater than max, write it to db.
             // so we can save memory
             if (textBuffer.length() > MAXDATACHARS) {
-                MetaCatUtil
-                        .debugMessage(
-                                "Write text into DB in charaters"
-                                        + " when text buffer size is greater than maxmum number",
-                                50);
+                logMetacat.info("Write text into DB in charaters"
+                       + " when text buffer size is greater than maxmum number");
                 DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
                 endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer,
                         currentNode);
@@ -898,9 +888,9 @@
             // we don't need to buffered it.
             StringBuffer inlineText = new StringBuffer();
             inlineText.append(new String(cbuf, start, len));
-            MetaCatUtil.debugMessage(
+            logMetacat.info(
                     "The inline text data write into file system: "
-                            + inlineText.toString(), 50);
+                            + inlineText.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineText);
         }
     }
@@ -909,13 +899,13 @@
     public void endElement(String uri, String localName, String qName)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("End ELEMENT " + qName, 50);
+        logMetacat.info("End ELEMENT " + qName);
 
         if (localName.equals(INLINE) && handleInlineData) {
             // Get the node from the stack
             DBSAXNode currentNode = (DBSAXNode) nodeStack.pop();
             String currentTag = currentNode.getTagName();
-            MetaCatUtil.debugMessage("End of inline data", 35);
+            logMetacat.info("End of inline data");
             // close file writer
             try {
                 inlineDataFileWriter.close();
@@ -934,19 +924,19 @@
                             .pop();
                     // get file name from db
                     String fileName = node.getNodeData();
-                    MetaCatUtil.debugMessage("in handle inline data", 35);
-                    MetaCatUtil.debugMessage(
+                    logMetacat.info("in handle inline data");
+                    logMetacat.info(
                             "the inline data file name from node is: "
-                                    + fileName, 40);
+                                    + fileName);
                     if (!compareInlineDataFiles(fileName, inlineDataFileName)) {
-                        MetaCatUtil.debugMessage(
+                        logMetacat.info(
                                 "inline data was changed by a user"
-                                        + " who doesn't have permission", 30);
+                                        + " who doesn't have permission");
                         throw new SAXException(PERMISSIONERROR);
                     }
                 } catch (EmptyStackException ee) {
-                    MetaCatUtil.debugMessage(
-                            "the stack is empty for text data", 32);
+                    logMetacat.error(
+                            "the stack is empty for text data");
                     throw new SAXException(PERMISSIONERROR);
                 } catch (McdbException eee) {
                     throw new SAXException(eee.getMessage());
@@ -1037,8 +1027,8 @@
                 // write text to db if it is not inline data
                 //if (!localName.equals(INLINE))
                 {
-                    MetaCatUtil.debugMessage(
-                            "Write text into DB in End Element", 50);
+                    logMetacat.info(
+                            "Write text into DB in End Element");
                     //compare text node if need
                     if (startCriticalSubTree) {
                         compareTextNode(currentUnChangedableSubtreeNodeStack,
@@ -1154,9 +1144,9 @@
                 if (needCheckingAccessModule && processTopLeverAccess
                         && !currentUnchangableAccessModuleNodeStack.isEmpty()) {
 
-                    MetaCatUtil.debugMessage(
+                    logMetacat.info(
                             "Access node stack is not empty after "
-                                    + "parsing access subtree", 40);
+                                    + "parsing access subtree");
                     throw new SAXException(UPDATEACCESSERROR);
 
                 }
@@ -1184,8 +1174,8 @@
             endElement.append("</");
             endElement.append(qName);
             endElement.append(">");
-            MetaCatUtil.debugMessage("inline endElement: "
-                    + endElement.toString(), 50);
+            logMetacat.info("inline endElement: "
+                    + endElement.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, endElement);
         }
     }
@@ -1195,7 +1185,7 @@
      */
     public void comment(char[] ch, int start, int length) throws SAXException
     {
-        MetaCatUtil.debugMessage("COMMENT", 50);
+        logMetacat.info("COMMENT");
         if (!handleInlineData) {
             if (!processingDTD) {
                 DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
@@ -1228,8 +1218,8 @@
             inlineComment.append("<!--");
             inlineComment.append(new String(ch, start, length));
             inlineComment.append("-->");
-            MetaCatUtil.debugMessage("inline data comment: "
-                    + inlineComment.toString(), 50);
+            logMetacat.info("inline data comment: "
+                    + inlineComment.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlineComment);
         }
     }
@@ -1242,31 +1232,26 @@
         try {
             node = (NodeRecord) nodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil.debugMessage("the stack is empty for comment data", 32);
+            logMetacat.error("the stack is empty for comment data");
             throw new SAXException(error);
         }
-        MetaCatUtil.debugMessage("current node type from xml is COMMENT", 40);
-        MetaCatUtil.debugMessage("node type from stack: " + node.getNodeType(),
-                40);
-        MetaCatUtil
-                .debugMessage("current node data from xml is: " + string, 40);
-        MetaCatUtil.debugMessage("node data from stack: " + node.getNodeData(),
-                40);
-        MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(), 40);
+        logMetacat.info("current node type from xml is COMMENT");
+        logMetacat.info("node type from stack: " + node.getNodeType());
+        logMetacat.info("current node data from xml is: " + string);
+        logMetacat.info("node data from stack: " + node.getNodeData());
+        logMetacat.info("node is from stack: " + node.getNodeId());
         // if not consistent terminate program and throw a exception
         if (!node.getNodeType().equals("COMMENT")
                 || !string.equals(node.getNodeData())) {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage("current node type from xml is COMMENT",
-                    40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + node.getNodeType(), 40);
-            MetaCatUtil.debugMessage(
-                    "current node data from xml is: " + string, 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + node.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(),
-                    40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info("current node type from xml is COMMENT");
+            logMetacat.info("node type from stack: "
+                    + node.getNodeType());
+            logMetacat.info(
+                    "current node data from xml is: " + string);
+            logMetacat.info("node data from stack: "
+                    + node.getNodeData());
+            logMetacat.info("node is from stack: " + node.getNodeId());
             throw new SAXException(error);
         }//if
     }
@@ -1278,7 +1263,7 @@
     public void processingInstruction(String target, String data)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("PI", 50);
+        logMetacat.info("PI");
         if (!handleInlineData) {
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             endNodeId = currentNode.writeChildNodeToDB("PI", target, data,
@@ -1290,8 +1275,8 @@
             inlinePI.append(" ");
             inlinePI.append(data);
             inlinePI.append("?>");
-            MetaCatUtil.debugMessage("inline data pi is: "
-                    + inlinePI.toString(), 50);
+            logMetacat.info("inline data pi is: "
+                    + inlinePI.toString());
             writeInlineDataIntoFile(inlineDataFileWriter, inlinePI);
         }
     }
@@ -1300,7 +1285,7 @@
     public void startPrefixMapping(String prefix, String uri)
             throws SAXException
     {
-        MetaCatUtil.debugMessage("NAMESPACE", 50);
+        logMetacat.info("NAMESPACE");
         if (!handleInlineData) {
             namespaces.put(prefix, uri);
         } else {
@@ -1318,7 +1303,7 @@
         // When validation is turned "on", white spaces are reported here
         // When validation is turned "off" white spaces are not reported here,
         // but through characters() callback
-        MetaCatUtil.debugMessage("IGNORABLEWHITESPACE", 50);
+        logMetacat.info("IGNORABLEWHITESPACE");
         if (!handleInlineData) {
             DBSAXNode currentNode = (DBSAXNode) nodeStack.peek();
             String data = null;
@@ -1381,23 +1366,21 @@
         try {
             node = (NodeRecord) nodeStack.pop();
         } catch (EmptyStackException ee) {
-            MetaCatUtil.debugMessage("the stack is empty for whitespace data",
-                    32);
+            logMetacat.error("the stack is empty for whitespace data");
             throw new SAXException(error);
         }
         if (!node.getNodeType().equals("TEXT")
                 || !string.equals(node.getNodeData())) {
-            MetaCatUtil.debugMessage("Inconsistence happend: ", 40);
-            MetaCatUtil.debugMessage(
-                    "current node type from xml is WHITESPACE TEXT", 40);
-            MetaCatUtil.debugMessage("node type from stack: "
-                    + node.getNodeType(), 40);
-            MetaCatUtil.debugMessage(
-                    "current node data from xml is: " + string, 40);
-            MetaCatUtil.debugMessage("node data from stack: "
-                    + node.getNodeData(), 40);
-            MetaCatUtil.debugMessage("node is from stack: " + node.getNodeId(),
-                    40);
+            logMetacat.info("Inconsistence happend: ");
+            logMetacat.info(
+                    "current node type from xml is WHITESPACE TEXT");
+            logMetacat.info("node type from stack: "
+                    + node.getNodeType());
+            logMetacat.info(
+                    "current node data from xml is: " + string);
+            logMetacat.info("node data from stack: "
+                    + node.getNodeData());
+            logMetacat.info("node is from stack: " + node.getNodeId());
             throw new SAXException(error);
         }//if
     }
@@ -1405,12 +1388,11 @@
     /** SAX Handler that receives notification of end of the document */
     public void endDocument() throws SAXException
     {
-        MetaCatUtil.debugMessage("end Document", 50);
+        logMetacat.info("end Document");
         // There are some unchangable subtree didn't be compare
         // This maybe cause user change the subtree id
         if (!unChangableSubTreeHash.isEmpty()) {
-            MetaCatUtil.debugMessage("The unChangealbe subtree is not empty",
-                    40);
+            logMetacat.info("The unChangealbe subtree is not empty");
             throw new SAXException(PERMISSIONERROR);
         }
         if (!super.getIsRevisionDoc())
@@ -1478,8 +1460,8 @@
                 // access object
                 String referenceId = accessSectionObj.getReferences();
                 boolean findAccessObject = false;
-                MetaCatUtil.debugMessage("referered id for top access: "
-                        + referenceId, 35);
+                logMetacat.info("referered id for top access: "
+                        + referenceId);
                 for (int i = 0; i < accessObjectList.size(); i++) {
                     AccessSection accessObj = (AccessSection) accessObjectList
                             .elementAt(i);
@@ -1543,8 +1525,8 @@
         }//if
         else {
             // couldn't find a access section object
-            MetaCatUtil.debugMessage(
-                    "couldn't find access control for document: " + docid, 35);
+            logMetacat.info(
+                    "couldn't find access control for document: " + docid);
         }
 
     }//writeTopLevelAccessRuletoDB
@@ -1573,7 +1555,7 @@
     {
         // make sure stack1 and stack2 are not empty
         if (stack1.isEmpty() || stack2.isEmpty()) {
-            MetaCatUtil.debugMessage("Because stack is empty!", 35);
+            logMetacat.info("Because stack is empty!");
             throw new SAXException(UPDATEACCESSERROR);
         }
         // go throw two stacks and compare every element
@@ -1585,16 +1567,15 @@
             try {
                 record2 = (NodeRecord) stack2.pop();
             } catch (EmptyStackException ee) {
-                MetaCatUtil.debugMessage(
-                        "Node stack2 is empty but stack1 isn't!", 35);
+                logMetacat.error(
+                        "Node stack2 is empty but stack1 isn't!");
                 throw new SAXException(UPDATEACCESSERROR);
             }
             // if two records are not same throw a exception
             if (!record1.contentEquals(record2)) {
-                MetaCatUtil
-                        .debugMessage(
+                logMetacat.info(
                                 "Two records from new and old stack are not "
-                                        + "same!", 30);
+                                        + "same!");
                 throw new SAXException(UPDATEACCESSERROR);
             }//if
         }//while
@@ -1601,9 +1582,9 @@
 
         // now stack1 is empty and we should make sure stack2 is empty too
         if (!stack2.isEmpty()) {
-            MetaCatUtil.debugMessage(
+            logMetacat.info(
                     "stack2 still have some elements while stack "
-                            + "is empty! ", 30);
+                            + "is empty! ");
             throw new SAXException(UPDATEACCESSERROR);
         }//if
     }//comparingNodeStacks
@@ -1628,9 +1609,9 @@
                 try {
                     // Get subsection id
                     String subSectionId = (String) en.nextElement();
-                    MetaCatUtil.debugMessage(
+                    logMetacat.info(
                             "sub section id in additional access mapping"
-                                    + "(go through): " + subSectionId, 35);
+                                    + "(go through): " + subSectionId);
 
                     if (subSectionId == null) {
                     // if id is null, terminate the program
@@ -1656,17 +1637,17 @@
                                     .getReferences();
 
                             boolean findAccessObject = false;
-                            MetaCatUtil.debugMessage(
+                            logMetacat.info(
                                     "referered id for additional access "
                                             + "mapping(go through): "
-                                            + referenceId, 35);
+                                            + referenceId);
                             for (int i = 0; i < accessObjectList.size(); i++) {
                                 AccessSection accessObj = (AccessSection) accessObjectList
                                         .elementAt(i);
                                 String accessObjId = accessObj.getSubTreeId();
-                                MetaCatUtil.debugMessage(
+                                logMetacat.info(
                                         "access obj id in the list(go through): "
-                                                + accessObjId, 35);
+                                                + accessObjId);
                                 if (referenceId != null && accessObj != null
                                         && referenceId.equals(accessObjId)) {
                                     writeGivenAccessRuleIntoDB(accessObj,
@@ -1684,9 +1665,9 @@
                 }//try
                 catch (Exception e) {
 
-                    MetaCatUtil.debugMessage(
+                    logMetacat.error(
                             "error in EmlSAXHandler.writeAddtionalAccess"
-                                    + ": " + e.getMessage(), 30);
+                                    + ": " + e.getMessage());
                     throw new SAXException(e.getMessage());
                 }
             }//while
@@ -1720,13 +1701,11 @@
             connection.increaseUsageCount(1);
             // Bind the values to the query
             pstmt.setString(1, docid);
-            MetaCatUtil.debugMessage("Docid in accesstable: " + docid, 35);
+            logMetacat.info("Docid in accesstable: " + docid);
             pstmt.setString(6, docid);
-            MetaCatUtil.debugMessage("Accessfileid in accesstable: " + docid,
-                    35);
+            logMetacat.info("Accessfileid in accesstable: " + docid);
             pstmt.setString(5, permOrder);
-            MetaCatUtil.debugMessage("PermOder in accesstable: " + permOrder,
-                    35);
+            logMetacat.info("PermOder in accesstable: " + permOrder);
             // if it is not top level, set subsection id
             if (!topLevel) {
                 long startNodeId = 0;
@@ -1749,13 +1728,12 @@
                         "Could find the subtree" + "for this id: "
                                 + subSectionId); }
                 pstmt.setString(7, subSectionId);
-                MetaCatUtil.debugMessage("SubSectionId in accesstable: "
-                        + subSectionId, 35);
+                logMetacat.info("SubSectionId in accesstable: "
+                        + subSectionId);
                 pstmt.setLong(8, startNodeId);
-                MetaCatUtil
-                        .debugMessage("Start node id is: " + startNodeId, 35);
+                logMetacat.info("Start node id is: " + startNodeId);
                 pstmt.setLong(9, endNodeId);
-                MetaCatUtil.debugMessage("End node id is: " + endNodeId, 35);
+                logMetacat.info("End node id is: " + endNodeId);
 
             }
 
@@ -1766,18 +1744,18 @@
                 String permType = rule.getPermissionType();
                 int permission = rule.getPermission();
                 pstmt.setInt(3, permission);
-                MetaCatUtil.debugMessage("permission in accesstable: "
-                        + permission, 35);
+                logMetacat.info("permission in accesstable: "
+                        + permission);
                 pstmt.setString(4, permType);
-                MetaCatUtil.debugMessage(
-                        "Permtype in accesstable: " + permType, 35);
+                logMetacat.info(
+                        "Permtype in accesstable: " + permType);
                 // go through every principle in rule
                 Vector nameVector = rule.getPrincipal();
                 for (int j = 0; j < nameVector.size(); j++) {
                     String prName = (String) nameVector.elementAt(j);
                     pstmt.setString(2, prName);
-                    MetaCatUtil.debugMessage("Principal in accesstable: "
-                            + prName, 35);
+                    logMetacat.info("Principal in accesstable: "
+                            + prName);
                     pstmt.execute();
                 }//for
             }//for
@@ -1820,13 +1798,11 @@
             connection.increaseUsageCount(1);
             // Bind the values to the query
             pstmt.setString(1, dataId);
-            MetaCatUtil.debugMessage("Docid in accesstable: " + docid, 35);
+            logMetacat.info("Docid in accesstable: " + docid);
             pstmt.setString(6, docid);
-            MetaCatUtil.debugMessage("Accessfileid in accesstable: " + docid,
-                    35);
+            logMetacat.info("Accessfileid in accesstable: " + docid);
             pstmt.setString(5, permOrder);
-            MetaCatUtil.debugMessage("PermOder in accesstable: " + permOrder,
-                    35);
+            logMetacat.info("PermOder in accesstable: " + permOrder);
             // if it is not top level, set subsection id
 
             Vector accessRules = accessSection.getAccessRules();
@@ -1836,18 +1812,18 @@
                 String permType = rule.getPermissionType();
                 int permission = rule.getPermission();
                 pstmt.setInt(3, permission);
-                MetaCatUtil.debugMessage("permission in accesstable: "
-                        + permission, 35);
+                logMetacat.info("permission in accesstable: "
+                        + permission);
                 pstmt.setString(4, permType);
-                MetaCatUtil.debugMessage(
-                        "Permtype in accesstable: " + permType, 35);
+                logMetacat.info(
+                        "Permtype in accesstable: " + permType);
                 // go through every principle in rule
                 Vector nameVector = rule.getPrincipal();
                 for (int j = 0; j < nameVector.size(); j++) {
                     String prName = (String) nameVector.elementAt(j);
                     pstmt.setString(2, prName);
-                    MetaCatUtil.debugMessage("Principal in accesstable: "
-                            + prName, 35);
+                    logMetacat.info("Principal in accesstable: "
+                            + prName);
                     pstmt.execute();
                 }//for
             }//for
@@ -1918,21 +1894,19 @@
             String sectionId = accessSection.getSubTreeId();
             // Bind the values to the query
             pstmt.setString(1, docid);
-            MetaCatUtil.debugMessage("Docid in access-subtreetable: " + docid,
-                    35);
+            logMetacat.info("Docid in access-subtreetable: " + docid);
             pstmt.setString(2, revision);
-            MetaCatUtil.debugMessage("rev in accesssubtreetable: " + revision,
-                    35);
+            logMetacat.info("rev in accesssubtreetable: " + revision);
             pstmt.setString(3, level);
-            MetaCatUtil.debugMessage("contorl level in access-subtree table: "
-                    + level, 35);
+            logMetacat.info("contorl level in access-subtree table: "
+                    + level);
             pstmt.setString(4, sectionId);
-            MetaCatUtil.debugMessage("Subtree id in access-subtree table: "
-                    + sectionId, 35);
+            logMetacat.info("Subtree id in access-subtree table: "
+                    + sectionId);
             pstmt.setLong(5, startNodeId);
-            MetaCatUtil.debugMessage("Start node id is: " + startNodeId, 35);
+            logMetacat.info("Start node id is: " + startNodeId);
             pstmt.setLong(6, endNodeId);
-            MetaCatUtil.debugMessage("End node id is: " + endNodeId, 35);
+            logMetacat.info("End node id is: " + endNodeId);
             pstmt.execute();
             pstmt.close();
         }//try
@@ -1985,7 +1959,7 @@
          * File inlineDataDirectory = new File(path);
          */
         String newFile = path + "/" + fileName;
-        MetaCatUtil.debugMessage("inline file name: " + newFile, 30);
+        logMetacat.info("inline file name: " + newFile);
         try {
             // true means append
             writer = new FileWriter(newFile, true);
@@ -2052,8 +2026,7 @@
         } catch (Exception e) {
             throw new McdbException(e.getMessage());
         }
-        MetaCatUtil.debugMessage("the inline data retrieve from file: " + data,
-                50);
+        logMetacat.info("the inline data retrieve from file: " + data);
         return same;
     }
 
@@ -2186,7 +2159,7 @@
      */
     private void handleOnlineUrlDataFile(String url) throws SAXException
     {
-      MetaCatUtil.debugMessage("The url is "+ url, 10);
+      logMetacat.warn("The url is "+ url);
       // if the url is not a ecogrid protocol, null will be getten
       String accessionNumber =
                  MetaCatUtil.getAccessionNumberFromEcogridIdentifier(url);
@@ -2213,9 +2186,9 @@
         }//try
         catch(Exception e)
         {
-          MetaCatUtil.debugMessage("Eorr in " +
+          logMetacat.error("Eorr in " +
                                 "Eml210SAXHanlder.handleOnlineUrlDataFile is " +
-                                 e.getMessage(), 30);
+                                 e.getMessage());
           throw new SAXException(e.getMessage());
         }
       }
Index: src/edu/ucsb/nceas/metacat/NodeRecord.java
===================================================================
--- src/edu/ucsb/nceas/metacat/NodeRecord.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/NodeRecord.java	(revision 2663)
@@ -27,6 +27,8 @@
 
 package edu.ucsb.nceas.metacat;
 
+import org.apache.log4j.Logger;
+
 /**
  * A utility class that encapsulates a node and its data
  */
@@ -38,6 +40,7 @@
   public String nodeprefix = null;
   public String nodetype = null;
   public String nodedata = null;
+  private Logger logMetacat = Logger.getLogger(NodeRecord.class);
 
   /**
    * Constructor
@@ -94,14 +97,14 @@
   public boolean contentEquals(NodeRecord record)
   {
     boolean flag = true;
-    MetaCatUtil.debugMessage("First nodetype: "+this.nodetype, 40);
-    MetaCatUtil.debugMessage("Second nodetype: "+record.getNodeType(), 40);
-    MetaCatUtil.debugMessage("First nodename: "+this.nodename, 40);
-    MetaCatUtil.debugMessage("Second nodename: "+record.getNodeName(), 40);
-    MetaCatUtil.debugMessage("First nodeprefix: "+this.nodeprefix, 40);
-    MetaCatUtil.debugMessage("Second nodeprefix: "+record.getNodePrefix(), 40);
-    MetaCatUtil.debugMessage("First nodedata: "+this.nodedata, 40);
-    MetaCatUtil.debugMessage("Second nodedata: "+record.getNodeData(), 40);
+    logMetacat.info("First nodetype: "+this.nodetype);
+    logMetacat.info("Second nodetype: "+record.getNodeType());
+    logMetacat.info("First nodename: "+this.nodename);
+    logMetacat.info("Second nodename: "+record.getNodeName());
+    logMetacat.info("First nodeprefix: "+this.nodeprefix);
+    logMetacat.info("Second nodeprefix: "+record.getNodePrefix());
+    logMetacat.info("First nodedata: "+this.nodedata);
+    logMetacat.info("Second nodedata: "+record.getNodeData());
     if ((this.nodename == null && record.getNodeName() != null) ||
         (this.nodename != null && record.getNodeName() == null) ||
         (this.nodename != null && record.getNodeName() != null &&
Index: src/edu/ucsb/nceas/metacat/ReplicationServerList.java
===================================================================
--- src/edu/ucsb/nceas/metacat/ReplicationServerList.java	(revision 2662)
+++ src/edu/ucsb/nceas/metacat/ReplicationServerList.java	(revision 2663)
@@ -32,6 +32,8 @@
 import java.util.Vector;
 import java.sql.*;
 
+import org.apache.log4j.Logger;
+
 /**
  * A class represent a replication server list in xml_replcation table
  */
@@ -40,7 +42,8 @@
 {
   private static Vector serverList = null; //Vector to store server list
   private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
-  
+  private static Logger logMetacat = Logger.getLogger(ReplicationServer.class);
+
   /**
    * constructor of ReplicationServerList
    * It will build server list. If only local host exists, ther server list
@@ -89,19 +92,19 @@
       {
         //Server name
         String serverName = rs.getString(1);
-        MetaCatUtil.debugMessage("ServerName: "+serverName, 40);
+        logMetacat.info("ServerName: "+serverName);
         //Last check date
         String lastChecked = rs.getString(2);
-        MetaCatUtil.debugMessage("Last checked time: "+lastChecked, 40);
+        logMetacat.info("Last checked time: "+lastChecked);
         //Replication value
         int replication = rs.getInt(3);
-        MetaCatUtil.debugMessage("Replication value: "+replication, 40);
+        logMetacat.info("Replication value: "+replication);
         //Data replication value
         int dataReplication = rs.getInt(4);
-        MetaCatUtil.debugMessage("DataReplication value: "+dataReplication, 40);
+        logMetacat.info("DataReplication value: "+dataReplication);
         //Hub value
         int hubValue = rs.getInt(5);
-        MetaCatUtil.debugMessage("Hub value: "+hubValue, 40);
+        logMetacat.info("Hub value: "+hubValue);
         //Get rid of local host
         if(!serverName.equals("localhost"))
         {
@@ -165,8 +168,8 @@
     }//try
     catch(Exception e)
     {
-      MetaCatUtil.debugMessage("Error in ReplicationServerList."
-                                    +"buildServerList(): "+e.getMessage(), 30);
+      logMetacat.error("Error in ReplicationServerList."
+                                    +"buildServerList(): "+e.getMessage());
     }//catch
     finally
     {
@@ -179,8 +182,8 @@
       }//try
       catch (SQLException sqlE)
       {
-        MetaCatUtil.debugMessage("Error in ReplicationHandler.buildServerList: "
-                                +sqlE.getMessage(), 30);
+        logMetacat.error("Error in ReplicationHandler.buildServerList: "
+                                +sqlE.getMessage());
       }//catch
       finally
       {
@@ -460,8 +463,8 @@
       }//try
       catch (Exception e)
       {
-        MetaCatUtil.debugMessage("Error in ReplicationServerList."+
-                            "addToServerListIfItIsNot: " + e.getMessage(), 30);
+        logMetacat.error("Error in ReplicationServerList."+
+                            "addToServerListIfItIsNot: " + e.getMessage());
       }//catch
       finally
       { 
@@ -471,8 +474,8 @@
         }//try
         catch (Exception ee)
         { 
-          MetaCatUtil.debugMessage("Error in ReplicationServerList."+
-                            "addToServerListIfItIsNot: " + ee.getMessage(), 50);
+          logMetacat.error("Error in ReplicationServerList."+
+                            "addToServerListIfItIsNot: " + ee.getMessage());
         }//catch
         finally
         {
