Index: test/edu/ucsb/nceas/metacattest/EventLogTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/EventLogTest.java	(revision 2110)
+++ test/edu/ucsb/nceas/metacattest/EventLogTest.java	(revision 2111)
@@ -26,6 +26,10 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import edu.ucsb.nceas.metacat.DBConnectionPool;
 import edu.ucsb.nceas.metacat.EventLog;
@@ -67,10 +71,38 @@
         assertTrue(logger != null);
     }
 
+    /**
+     * Test whether the log method can properly insert a log record.
+     */
     public void testLog()
     {
-        EventLog.getInstance().log("192.168.1.103", "public", "test.1", "read");
+        EventLog.getInstance().log("192.168.1.103", "public", "test.2.1", "read");
         assertTrue(1 == 1);
     }
 
+    /**
+     * Test whether getReport returns correct reports.
+     */
+    public void testGetReport()
+    {
+        String[] principals = {"jones", "public", "someone"};
+        String[] ipList = {"192.168.1.103", "192.168.1.104"};
+        String[] docList = {"test.2.1", "test.2"};
+        String[] eventList = {"read", "insert", "update"};
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Timestamp startDate = null;
+        Timestamp endDate = null;
+        try {
+            startDate = new Timestamp((format.parse("2004-04-07 09:32:00")).getTime());
+            endDate = new Timestamp((format.parse("2004-04-07 09:50:00")).getTime());
+        } catch (ParseException e) {
+            System.out.println("Failed to created endDate from format.");
+        }
+        String report = EventLog.getInstance().getReport(ipList, principals, docList, 
+                        eventList, null, null);
+        System.out.println(report);
+        report = EventLog.getInstance().getReport(null, null, null, 
+                        null, startDate, endDate);
+        System.out.println(report);
+    }
 }
Index: src/edu/ucsb/nceas/metacat/EventLog.java
===================================================================
--- src/edu/ucsb/nceas/metacat/EventLog.java	(revision 2110)
+++ src/edu/ucsb/nceas/metacat/EventLog.java	(revision 2111)
@@ -24,6 +24,7 @@
 package edu.ucsb.nceas.metacat;
 
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Timestamp;
 import java.util.Date;
@@ -118,7 +119,7 @@
         int serialNumber = -1;
         try {
             // Get a database connection from the pool
-            dbConn = DBConnectionPool.getDBConnection("EventLog.writeLog");
+            dbConn = DBConnectionPool.getDBConnection("EventLog.insertLogEntry");
             serialNumber = dbConn.getCheckOutSerialNumber();
             
             // Execute the insert statement
@@ -137,7 +138,7 @@
     
     /**
      * Get a report of the log events that match a set of filters.  The
-     * filter parameters can be omitted null; log records are subset based on
+     * filter parameters can be null; log records are subset based on
      * non-null filter parameters.
      * 
      * @param ipAddress the internet protocol address for the event
@@ -144,11 +145,167 @@
 	 * @param principal the principal for the event (a username, etc)
 	 * @param docid the identifier of the document to which the event applies
 	 * @param event the string code for the event
-	 * @param startDate the date on which the event was logged
-	 * @param endDate the 
+	 * @param startDate beginning of date range for query
+	 * @param endDate end of date range for query
+	 * @return an XML-formatted report of the access log entries
      */
-    public void getReport(String ipAddress, String principal, String docid,
-            String event, Timestamp dateLogged)
+    public String getReport(String[] ipAddress, String[] principal, String[] docid,
+            String[] event, Timestamp startDate, Timestamp endDate)
     {
+        StringBuffer resultDoc = new StringBuffer();
+        StringBuffer query = new StringBuffer();
+        query.append("select entryid, ip_address, principal, docid, "
+            + "event, date_logged from access_log");
+//                        + ""
+//                        + "event, date_logged) " + "values (" + "'"
+//                        + logData.getIpAddress() + "', " + "'"
+//                        + logData.getPrincipal() + "', " + "'"
+//                        + logData.getDocid() + "', " + "'" + logData.getEvent()
+//                        + "', " + " ? " + ")";
+        if (ipAddress != null || principal != null || docid != null
+                        || event != null || startDate != null || endDate != null) {
+            query.append(" where ");
+        }
+        boolean clauseAdded = false;
+        int startIndex = 0;
+        int endIndex = 0;
+        
+        if (ipAddress != null) {
+            query.append(formatSqlClause(clauseAdded, "ip_address", ipAddress));
+            clauseAdded = true;
+        }
+        if (principal != null) {
+            query.append(formatSqlClause(clauseAdded, "principal", principal));
+            clauseAdded = true;
+        }
+        if (docid != null) {
+            query.append(formatSqlClause(clauseAdded, "docid", docid));
+            clauseAdded = true;
+        }
+        if (event != null) {
+            query.append(formatSqlClause(clauseAdded, "event", event));
+            clauseAdded = true;
+        }
+        if (startDate != null) {
+            if (clauseAdded) {
+                query.append(" and ");
+            }
+            query.append("date_logged > ?");
+            clauseAdded = true;
+            startIndex++;
+        }
+        if (endDate != null) {
+            if (clauseAdded) {
+                query.append(" and ");
+            }
+            query.append("date_logged < ?");
+            clauseAdded = true;
+            endIndex = startIndex + 1;
+        }
+        DBConnection dbConn = null;
+        int serialNumber = -1;
+        try {
+            // Get a database connection from the pool
+            dbConn = DBConnectionPool.getDBConnection("EventLog.getReport");
+            serialNumber = dbConn.getCheckOutSerialNumber();
+
+            // Execute the insert statement
+            System.out.println(query.toString());
+            PreparedStatement stmt = dbConn.prepareStatement(query.toString());
+            if (startIndex > 0) {
+                stmt.setTimestamp(startIndex, startDate); 
+            }
+            if (endIndex > 0) {
+                stmt.setTimestamp(endIndex, endDate);
+            }
+            stmt.execute();
+            ResultSet rs = stmt.getResultSet();
+            //process the result
+            resultDoc.append("<?xml version=\"1.0\"?>\n");
+            resultDoc.append("<log>\n");
+            while (rs.next()) {
+                resultDoc.append(formatXmlRecord(rs.getString(1), rs.getString(2),
+                                rs.getString(3), rs.getString(4), 
+                                rs.getString(5), rs.getTimestamp(6)));
+            }
+            resultDoc.append("</log>");
+            stmt.close();
+        } catch (SQLException e) {
+            MetaCatUtil.debugMessage("Error while logging event to database: "
+                            + e.getMessage(), 5);
+        } finally {
+            // Return database connection to the pool
+            DBConnectionPool.returnDBConnection(dbConn, serialNumber);
+        }
+        return resultDoc.toString();
     }
+    
+    /**
+     * Utility method to help build a SQL query from an array of values.  For each
+     * value in the array an 'OR' clause is constructed.
+     * 
+     * @param addOperator a flag indicating whether to add an 'AND' operator 
+     *                    to the clause
+     * @param column the name of the column to filter against
+     * @param values the values to match in the SQL query
+     * @return a String representation of the SQL query clause
+     */
+    private String formatSqlClause(boolean addOperator, String column, String[] values)
+    {
+        StringBuffer clause = new StringBuffer();
+        if (addOperator) {
+            clause.append(" and ");
+        }
+        clause.append("(");
+        for (int i = 0; i < values.length; i++) {
+            if (i > 0) {
+                clause.append(" or ");
+            }
+            clause.append(column);
+            clause.append(" like '");
+            clause.append(values[i]);
+            clause.append("'");
+        }
+        clause.append(")");
+        return clause.toString();
+    }
+    
+    /**
+     * Format each returned log record as an XML structure.
+     * 
+     * @param entryId the identifier of the log entry
+     * @param ipAddress the internet protocol address for the event
+	 * @param principal the principal for the event (a username, etc)
+	 * @param docid the identifier of the document to which the event applies
+	 * @param event the string code for the event
+     * @param dateLogged the date on which the event occurred
+     * @return String containing the formatted XML
+     */
+    private String formatXmlRecord(String entryId, String ipAddress, String principal, 
+                    String docid, String event, Timestamp dateLogged)
+    {
+        StringBuffer rec = new StringBuffer();
+        rec.append("<logEntry>");
+        rec.append(formatXmlElement("entryid", entryId));
+        rec.append(formatXmlElement("ipAddress", ipAddress));
+        rec.append(formatXmlElement("principal", principal));
+        rec.append(formatXmlElement("docid", docid));
+        rec.append(formatXmlElement("event", event));
+        rec.append(formatXmlElement("dateLogged", dateLogged.toString()));
+        rec.append("</logEntry>\n");
+
+        return rec.toString();
+    }
+    
+    /**
+     * Return an XML formatted element for a given name/value pair.
+     * 
+     * @param name the name of the xml element
+     * @param value the content of the xml element
+     * @return the formatted XML element as a String
+     */
+    private String formatXmlElement(String name, String value)
+    {
+        return "<" + name + ">" + value + "</" + name + ">";
+    }
 }
