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.tools.store.ResourceFrame
|
+----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
-
ATTR_LOGFILE
- Attribute index - The log file to use to emit log record.
-
ATTR_REPLY_HEADERS
- Attribute index - The HTTP reply headers to dump
-
ATTR_REQUEST_HEADERS
- Attribute index - The HTTP request headers to dump
-
DONT_LOG
- Name of the state that when set on the request will prevent logging.
-
log
- Open log descriptor, to write to the log.
-
repheaders
- Compiled index of the reply headers to dump.
-
reqheaders
- Compiled index of the request headers to dump.
-
LogFilter()
-
-
compileHeaders(HttpMessage, String[])
- Compile the given set of header names into header indexes.
-
getLogfile()
- Get the log file.
-
getReplyHeaders()
- Get the list of reply headers to dump.
-
getRequestHeaders()
- Get the list of request headers to dump.
-
ingoingFilter(Request)
- Nothing done at ingoing time.
-
initialize(Object[])
- Initialize the filter.
-
log(Request, Reply)
- Log the given request/reply transaction.
-
openLog()
- Open the log stream, and make it available through
log
.
-
outgoingFilter(Request, Reply)
- Log the request.
-
setValue(int, Object)
- Traop setValue calls.
-
writelog(String)
- Write the given string to the log file.
DONT_LOG
public static final String DONT_LOG
- Name of the state that when set on the request will prevent logging.
ATTR_REQUEST_HEADERS
protected static int ATTR_REQUEST_HEADERS
- Attribute index - The HTTP request headers to dump
ATTR_REPLY_HEADERS
protected static int ATTR_REPLY_HEADERS
- Attribute index - The HTTP reply headers to dump
ATTR_LOGFILE
protected static int ATTR_LOGFILE
- Attribute index - The log file to use to emit log record.
reqheaders
protected HeaderDescription reqheaders[]
- Compiled index of the request headers to dump.
repheaders
protected HeaderDescription repheaders[]
- Compiled index of the reply headers to dump.
log
protected RandomAccessFile log
- Open log descriptor, to write to the log.
LogFilter
public LogFilter()
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.
writelog
protected synchronized void writelog(String record)
- Write the given string to the log file.
- Parameters:
- record - The string to write.
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.
getLogfile
public File getLogfile()
- Get the log file.
- Returns:
- A File instance, or null if not set.
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.
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.
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
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.
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
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
initialize
public void initialize(Object values[])
- Initialize the filter.
- Overrides:
- initialize in class ResourceFilter
All Packages Class Hierarchy This Package Previous Next Index