Class w3c.jigsaw.contrib.LogFilter
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.contrib.LogFilter

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.ResourceFilter
                           |
                           +----w3c.jigsaw.contrib.LogFilter

public class LogFilter
extends ResourceFilter
This filter provides a very flexible logger. It is not designed as a logger, in order to be plugable only on a sub-tree of the URL space (a logger would log all site accesses). It provides as much details as you want, and uses a very simple format: each log entry (or record is made of several lines having the folowing format:
variable=value
A record starts with the special url variable value which provides the requested URL. The for each header that is to be logged, a variable is added in the record, prefixed by its scope. The scope can be either:
request
to specify a request header,
reply
to specify a reply header,
server
to specify global server samples.
As an example, if you configure that filter to log the request's referer and the reply content length, a sample record will look like:
url=http://www.w3.org/pub/WWW/Jigsaw/
request.referer=http://www.w3.org/pub/WWW
reply.content-length=10

Variable Index

 o ATTR_LOGFILE
Attribute index - The log file to use to emit log record.
 o ATTR_REPLY_HEADERS
Attribute index - The HTTP reply headers to dump
 o ATTR_REQUEST_HEADERS
Attribute index - The HTTP request headers to dump
 o DONT_LOG
Name of the state that when set on the request will prevent logging.
 o log
Open log descriptor, to write to the log.
 o repheaders
Compiled index of the reply headers to dump.
 o reqheaders
Compiled index of the request headers to dump.

Constructor Index

 o LogFilter()

Method Index

 o compileHeaders(HttpMessage, String[])
Compile the given set of header names into header indexes.
 o getLogfile()
Get the log file.
 o getReplyHeaders()
Get the list of reply headers to dump.
 o getRequestHeaders()
Get the list of request headers to dump.
 o ingoingFilter(Request)
Nothing done at ingoing time.
 o initialize(Object[])
Initialize the filter.
 o log(Request, Reply)
Log the given request/reply transaction.
 o openLog()
Open the log stream, and make it available through log.
 o outgoingFilter(Request, Reply)
Log the request.
 o setValue(int, Object)
Traop setValue calls.
 o writelog(String)
Write the given string to the log file.

Variables

 o DONT_LOG
  public final static String DONT_LOG
Name of the state that when set on the request will prevent logging.
 o ATTR_REQUEST_HEADERS
  protected static int ATTR_REQUEST_HEADERS
Attribute index - The HTTP request headers to dump
 o ATTR_REPLY_HEADERS
  protected static int ATTR_REPLY_HEADERS
Attribute index - The HTTP reply headers to dump
 o ATTR_LOGFILE
  protected static int ATTR_LOGFILE
Attribute index - The log file to use to emit log record.
 o reqheaders
  protected HeaderDescription reqheaders[]
Compiled index of the request headers to dump.
 o repheaders
  protected HeaderDescription repheaders[]
Compiled index of the reply headers to dump.
 o log
  protected RandomAccessFile log
Open log descriptor, to write to the log.

Constructors

 o LogFilter
  public LogFilter()

Methods

 o compileHeaders
  protected HeaderDescription[] compileHeaders(HttpMessage kind,
                                               String headers[])
Compile the given set of header names into header indexes.
Parameters:
kind - An instance of the class whose headers are to be dumped.
headers - The name of headers to compile.
Returns:
An array of header description, which will allow fast fetch of header values.
 o writelog
  protected synchronized void writelog(String record)
Write the given string to the log file.
Parameters:
record - The string to write.
 o openLog
  protected synchronized void openLog()
Open the log stream, and make it available through log. If opening the stream failed, an appropriate error message is emitted and log remains set to null. If a log stream was already opened, it is first closed.
 o getLogfile
  public File getLogfile()
Get the log file.
Returns:
A File instance, or null if not set.
 o getRequestHeaders
  public String[] getRequestHeaders()
Get the list of request headers to dump.
Returns:
An array of String containing the name of headers to dump, or null if undefined.
 o getReplyHeaders
  public String[] getReplyHeaders()
Get the list of reply headers to dump.
Returns:
An array of String containing the name of headers to dump, or null if undefined.
 o setValue
  public void setValue(int idx,
                       Object value)
Traop setValue calls. We maintain a compiled version of both the request-headers and the reply-headers attributes, make sure they stay in sync even when modified.
Overrides:
setValue in class Resource
 o log
  protected void log(Request request,
                     Reply reply)
Log the given request/reply transaction. Dump a record for the given transaction.
Parameters:
request - The request to log.
reply - It's associated reply.
 o ingoingFilter
  public Reply ingoingFilter(Request request) throws HTTPException
Nothing done at ingoing time.
Parameters:
request - The request to be handled.
Overrides:
ingoingFilter in class ResourceFilter
 o outgoingFilter
  public Reply outgoingFilter(Request request,
                              Reply reply) throws HTTPException
Log the request.
Parameters:
request - The request that has been handled.
reply - It's associated reply.
Overrides:
outgoingFilter in class ResourceFilter
 o initialize
  public void initialize(Object values[])
Initialize the filter.
Overrides:
initialize in class ResourceFilter

All Packages  Class Hierarchy  This Package  Previous  Next  Index