org.mortbay.http
Class NCSARequestLog

java.lang.Object
  extended by org.mortbay.http.NCSARequestLog
All Implemented Interfaces:
java.io.Serializable, RequestLog, LifeCycle

public class NCSARequestLog
extends java.lang.Object
implements RequestLog

NCSA HTTP Request Log. NCSA common or NCSA extended (combined) request log.

Version:
$Id: NCSARequestLog.java,v 1.35 2005/08/13 00:01:24 gregwilkins Exp $
Author:
Tony Thompson, Greg Wilkins
See Also:
Serialized Form

Constructor Summary
NCSARequestLog()
          Constructor.
NCSARequestLog(java.lang.String filename)
          Constructor.
 
Method Summary
 java.lang.String getDatedFilename()
          Get the dated log filename.
 java.lang.String getFilename()
          Get the log filename.
 java.lang.String[] getIgnorePaths()
           
 boolean getLogCookies()
           
 java.lang.String getLogDateFormat()
           
 boolean getLogLatency()
           
 java.lang.String getLogTimeZone()
           
 int getRetainDays()
           
 boolean isAppend()
           
 boolean isExtended()
           
 boolean isStarted()
           
 void log(HttpRequest request, HttpResponse response, int responseLength)
          Log a request.
protected  void logExtended(HttpRequest request, HttpResponse response, java.io.Writer log)
          Log Extended fields.
 void setAppend(boolean a)
           
 void setBuffered(boolean b)
          Deprecated. ignored
 void setExtended(boolean e)
           
 void setFilename(java.lang.String filename)
          Set the log filename.
 void setIgnorePaths(java.lang.String[] ignorePaths)
          Set which paths to ignore.
 void setLogCookies(boolean logCookies)
           
 void setLogDateFormat(java.lang.String format)
           
 void setLogLatency(boolean logLatency)
           
 void setLogTimeZone(java.lang.String tz)
           
 void setPreferProxiedForAddress(boolean value)
          Prefer to log the proxied-for IP address (if present in the request header) over the native requester IP address.
 void setRetainDays(int retainDays)
           
 void start()
          Start the LifeCycle.
 void stop()
          Stop the LifeCycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NCSARequestLog

public NCSARequestLog()
Constructor.


NCSARequestLog

public NCSARequestLog(java.lang.String filename)
               throws java.io.IOException
Constructor.

Parameters:
filename - Filename, which can be in rolloverFileOutputStream format
Throws:
java.io.IOException
See Also:
RolloverFileOutputStream
Method Detail

setFilename

public void setFilename(java.lang.String filename)
Set the log filename.

Parameters:
filename - The filename to use. If the filename contains the string "yyyy_mm_dd", then a RolloverFileOutputStream is used and the log is rolled over nightly and aged according setRetainDays. If no filename is set or a null filename passed, then requests are logged to System.err.
See Also:
setRetainDays(int)

getFilename

public java.lang.String getFilename()
Get the log filename.

Returns:
The log filename without any date expansion.
See Also:
getDatedFilename()

getDatedFilename

public java.lang.String getDatedFilename()
Get the dated log filename.

Returns:
The log filename with any date encoding expanded.
See Also:
getFilename()

setLogDateFormat

public void setLogDateFormat(java.lang.String format)
Parameters:
format - The date format to use within the log file.

getLogDateFormat

public java.lang.String getLogDateFormat()
Returns:
The date format to use within the log file.

setLogTimeZone

public void setLogTimeZone(java.lang.String tz)
Parameters:
tz - The date format timezone to use within the log file.

getLogTimeZone

public java.lang.String getLogTimeZone()
Returns:
The date format timezone to use within the log file.

getRetainDays

public int getRetainDays()
Returns:
The number of days to retain rollovered log files.

setRetainDays

public void setRetainDays(int retainDays)
Parameters:
retainDays - The number of days to retain rollovered log files.

isExtended

public boolean isExtended()
Returns:
True if NCSA extended format is to be used.

setExtended

public void setExtended(boolean e)
Parameters:
e - True if NCSA extended format is to be used.

isAppend

public boolean isAppend()
Returns:
True if logs are appended to existing log files.

setAppend

public void setAppend(boolean a)
Parameters:
a - True if logs are appended to existing log files.

setBuffered

public void setBuffered(boolean b)
Deprecated. ignored


setIgnorePaths

public void setIgnorePaths(java.lang.String[] ignorePaths)
Set which paths to ignore.

Parameters:
ignorePaths - Array of path specifications to ignore

getIgnorePaths

public java.lang.String[] getIgnorePaths()

getLogCookies

public boolean getLogCookies()
Returns:
Returns the logCookies.

setLogCookies

public void setLogCookies(boolean logCookies)
Parameters:
logCookies - The logCookies to set.

getLogLatency

public boolean getLogLatency()
Returns:
Returns true if logging latency

setLogLatency

public void setLogLatency(boolean logLatency)
Parameters:
logLatency - If true, latency is logged at the end of the log line

setPreferProxiedForAddress

public void setPreferProxiedForAddress(boolean value)
Prefer to log the proxied-for IP address (if present in the request header) over the native requester IP address. Useful in reverse-proxy situations when you'd rather see the IP address of the host before the most recent proxy server, as opposed to your own proxy server(s) every time. jlrobins@socialserve.com, March 2004.


start

public void start()
           throws java.lang.Exception
Description copied from interface: LifeCycle
Start the LifeCycle.

Specified by:
start in interface LifeCycle
Throws:
java.lang.Exception - An arbitrary exception may be thrown.

isStarted

public boolean isStarted()
Specified by:
isStarted in interface LifeCycle
Returns:
True if the LifeCycle has been started.

stop

public void stop()
Description copied from interface: LifeCycle
Stop the LifeCycle. The LifeCycle may wait for current activities to complete normally, but it can be interrupted.

Specified by:
stop in interface LifeCycle

log

public void log(HttpRequest request,
                HttpResponse response,
                int responseLength)
Log a request.

Specified by:
log in interface RequestLog
Parameters:
request - The request
response - The response to this request.
responseLength - The bytes written to the response.

logExtended

protected void logExtended(HttpRequest request,
                           HttpResponse response,
                           java.io.Writer log)
                    throws java.io.IOException
Log Extended fields. This method can be extended by a derived class to add extened fields to each log entry. It is called by the log method after all standard fields have been added, but before the line terminator. Derived implementations should write extra fields to the Writer provided. The default implementation writes the referer and user agent.

Parameters:
request - The request to log.
response - The response to log.
log - The writer to write the extra fields to.
Throws:
java.io.IOException - Problem writing log


Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.