org.apache.tomcat.modules.loggers
Class AccessLogInterceptor

java.lang.Object
  |
  +--org.apache.tomcat.core.BaseInterceptor
        |
        +--org.apache.tomcat.modules.loggers.AccessLogInterceptor

public class AccessLogInterceptor
extends BaseInterceptor

This is a TomCat RequestInterceptor that creates log files in the style of the Apache servers "AccessLog". It used by embedding a line like the following into server.xml:

   <RequestInterceptor
     className="org.apache.tomcat.logging.AccessLogInterceptor"
     logFile="logs/AccessLog" format="combined"/>
 

Possible attributes of the above XML element are:
logFile Name of the logfile being generated. Defaults to "logs/AccessLog". Tomcat.home is prepended, if the file name is relative.
flush An optional boolean attribute, that enables (value = "true") or disables (value="false", default) flushing the log file after every request. For performance reasons, you should not enable flushing unless you are debugging this class.
format A string describing the logfile format. Possible values are "combined" (Apache httpd combined format, default), "common" (Apache httpd common format) or a format string like
         '%h %l %u %t "%r" %>s %b "%{Referer}" "%{User-Agent}"'
         '%h %l %u %t "%r" %>s %b'
       
(The above examples are used when "combined" or "common" format is requested.) Possible patterns are: .
%% The percent character itself
%{var} The value of request.getHeader("var") or empty string for null.
%b The value of response.getContentLength().
%h The value of request.getRemoteHost().
%l Should be the remote users name, as indicated by an identd lookup. Currently it is always "-".
%r First line of the request submitted by the client, for example
               GET /index.html?frame=main HTTP/1.0
             
The first line is rebuilt from the values of request.getMethod(), request.getRequestURI(), request.getQueryString() and request.getProtocol(). It should probably better be recorded while reading the headers.
%s The value of response.getStatus().
%>s The value of response.getStatus(). Should differ between different internal requests, as Apache httpd does, but this is currently not supported.
%t The current time and date in the format
               [20/Apr/2001:19:45:23 0200]
             
%u The value of request.getRemoteUser() or "-" for null.

Author:
Jochen Wiedmann, jochen.wiedmann@softwareag.com

Fields inherited from class org.apache.tomcat.core.BaseInterceptor
cm, ct, ctx, debug, DECLINED, loghelper, OK
 
Constructor Summary
AccessLogInterceptor()
          Creates a new AccessLogInterceptor
 
Method Summary
 int beforeCommit(Request request, Response response)
          This method is actually creating an entry in the log file.
 void engineShutdown(ContextManager cm)
          Shut down the module.
static void setFlush(boolean flush)
          Enables (true) or disables (false, default) flushing the log file after any request.
static void setFormat(java.lang.String format)
          Sets the logfile format.
static void setLogFile(java.lang.String logFile)
          Sets the logfile name.
 
Methods inherited from class org.apache.tomcat.core.BaseInterceptor
addContainer, addContext, addHandler, addInterceptor, addSecurityConstraint, afterBody, authenticate, authorize, beforeBody, contextInit, contextMap, contextShutdown, contextState, engineInit, engineStart, engineState, engineStop, findSession, getContext, getContextManager, getDebug, getInfo, getLog, getNote, getNote, handleError, log, log, log, log, postReadRequest, postRequest, postService, postServletDestroy, postServletInit, preService, preServletDestroy, preServletInit, registerHooks, reload, removeContainer, removeContext, removeHandler, removeInterceptor, requestMap, sessionState, setContext, setContextManager, setDebug, setInfo, setNote, setNote
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccessLogInterceptor

public AccessLogInterceptor()
Creates a new AccessLogInterceptor
Method Detail

setLogFile

public static void setLogFile(java.lang.String logFile)

Sets the logfile name.


setFlush

public static void setFlush(boolean flush)

Enables (true) or disables (false, default) flushing the log file after any request.


setFormat

public static void setFormat(java.lang.String format)

Sets the logfile format.


beforeCommit

public int beforeCommit(Request request,
                        Response response)

This method is actually creating an entry in the log file.

Overrides:
beforeCommit in class BaseInterceptor

engineShutdown

public void engineShutdown(ContextManager cm)
                    throws TomcatException
Description copied from class: BaseInterceptor
Shut down the module.
Overrides:
engineShutdown in class BaseInterceptor
Following copied from class: org.apache.tomcat.core.BaseInterceptor
Throws:
If - any exception is reported, the module will be removed. XXX (?)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.