DLESE Tools
v1.6.0

org.dlese.dpc.logging
Class ClfLogger

java.lang.Object
  extended by org.dlese.dpc.logging.ClfLogger

public class ClfLogger
extends Object

This implements the DLESE extended form of the combined log format as documented at Apache logs docs.

The combined log format has the same first seven fields as the common log format, and adds two more fields: referrer and user-agent.

The DLESE extension to the combined log format adds several more fields, documented below.

The fields, with their normal CGI variable names, are:

Common log format:

REMOTE_HOST
Remote host IP number.
Example: 64.124.140.181
id
See rfc1413 (obsoletes rfc931) remote logname of the user. Unreliable, seldom used. Usually appears as "-".
Example: -
REMOTE_USER
The username as which the user has authenticated via password protection.
Example: -
Example: samuel
Date/time
The date and time of request, UTC (GMT) time.
Note: this is the time when the server wrote the log record, not the time extracted from the possibly bogus date header.
Example: [10/Nov/2002:07:48:54 -0700]
Request string
The request line as it came from the client. Note: this is reconstructed using HttpServletRequest calls, so there may be slight differences in formatting from the original request string.
Example: "GET /testldap/tldap HTTP/1.1"
Status
The HTTP status code returned to the client.
Example: 200
Content length
The content length of the document returned to the client.
Example: 7638

Combined log format extensions:

Referer
The referer HTTP request header, in quotes. Someone long ago ago misspelled "referrer" and it's never been fixed. If unavailable, it appears quoted as "-", not as -.
Example: "-"
Example: "http://quake.dpc.ucar.edu/index.html"
User Agent
The User_Agent HTTP request header, in quotes. If unavailable, it appears quoted as "-", not as -.
Example: "-"
Example: "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529"

DLESE extensions:

SERVER_NAME
The name of the server that received the request.
Example: localhost
SERVER_PORT
The port number of the server that received the request.
Example: 80
requestType
The DLESE request type:
Example: search
numSearchResults
Number of search results for "search" requests; 0 otherwise.
Example: 98
numDbRecords
Total number of records in the database.
Example: 9000
rankNum
If "search": rank of first result in the displayed page. If "full": rank of this result. If "other": 0.
Example: 1
dleseId
If "full": the DLESE ID of the record returned. Otherwise: "-"
Example: "-"
xmlString
An arbitrary string, generally XML. Internal backslashes, quotes, double quotes, newlines, etc. will be escaped.
Example: "<criteria testattr=\"testval\"><field>Free Text</field><textSearchValue>oceanography</textSearchValue><textSearchTerm>oceanography</textSearchTerm><field>Grade Level</field><LearningContext>High school</LearningContext></criteria>"

Sample Usage

 public class TestServlet extends HttpServlet {
 
 ClfLogger logger = null;
 public void init( ServletConfig conf)
 throws ServletException
 {
     super.init(conf);
 
     String logfile = getInitParameter("test.log.file.name");
     try {
         logger = DleseLogManager.getClfLogger(
             Level.FINEST,  // minimum level this logger will accept
             true,          // append
             logfile);      // output log file
     }
     catch( LogException dle) {
         log("cannot init ClfLogger: " + dle);
         logger = null;
     }
 } // end init
 
 
 
 public void doGet(
     HttpServletRequest req,
     HttpServletResponse resp)
 throws IOException, ServletException
 {
     int statusCode = 200;
     int contentLen = 0;
     int numSearchResults = 98;
     int numDbRecs = 9000;
     int rankNum = 1;
     String xmlString
         = "<someTag someAttr="xyz">some contents</someTag>";
     logger.log(
         java.util.logging.Level.SEVERE,  // message importance
         req,                // the incoming request
         statusCode,         // returned http status code
         contentLen,         // returned content len, bytes
         "search",           // type: search, full, or other
         numSearchResults,   // num search results
         numDbRecs,          // total num records in the database
         rankNum,            // if search: rank of first rec in page
                             // if full: rank of this rec
         null,               // dleseId: if full: dlese ID of this rec
         xmlString);         // xml stg.  Will appear in double quotes.
                             // Internal backslashes, quotes, double quotes,
                             // newlines, etc. will be escaped.
 } // end doGet
 } // end class TestServlet
 


Method Summary
 void close()
           
 void log(Level level, HttpServletRequest req, int statusCode, int contentLen, String requestType, int numSearchResults, int numDbRecords, int rankNum, String dleseId, String xmlString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

close

public void close()
           throws LogException
Throws:
LogException

log

public void log(Level level,
                HttpServletRequest req,
                int statusCode,
                int contentLen,
                String requestType,
                int numSearchResults,
                int numDbRecords,
                int rankNum,
                String dleseId,
                String xmlString)

DLESE Tools
v1.6.0