org.mortbay.http

Class NCSARequestLog

public class NCSARequestLog extends 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

Constructor Summary
NCSARequestLog()
Constructor.
NCSARequestLog(String filename)
Constructor.
Method Summary
StringgetDatedFilename()
Get the dated log filename.
StringgetFilename()
Get the log filename.
String[]getIgnorePaths()
booleangetLogCookies()
StringgetLogDateFormat()
booleangetLogLatency()
StringgetLogTimeZone()
intgetRetainDays()
booleanisAppend()
booleanisExtended()
booleanisStarted()
voidlog(HttpRequest request, HttpResponse response, int responseLength)
Log a request.
protected voidlogExtended(HttpRequest request, HttpResponse response, Writer log)
Log Extended fields.
voidsetAppend(boolean a)
voidsetBuffered(boolean b)
voidsetExtended(boolean e)
voidsetFilename(String filename)
Set the log filename.
voidsetIgnorePaths(String[] ignorePaths)
Set which paths to ignore.
voidsetLogCookies(boolean logCookies)
voidsetLogDateFormat(String format)
voidsetLogLatency(boolean logLatency)
voidsetLogTimeZone(String tz)
voidsetPreferProxiedForAddress(boolean value)
Prefer to log the proxied-for IP address (if present in the request header) over the native requester IP address.
voidsetRetainDays(int retainDays)
voidstart()
voidstop()

Constructor Detail

NCSARequestLog

public NCSARequestLog()
Constructor.

NCSARequestLog

public NCSARequestLog(String filename)
Constructor.

Parameters: filename Filename, which can be in rolloverFileOutputStream format

Throws: IOException

See Also: RolloverFileOutputStream

Method Detail

getDatedFilename

public String getDatedFilename()
Get the dated log filename.

Returns: The log filename with any date encoding expanded.

See Also: getFilename

getFilename

public String getFilename()
Get the log filename.

Returns: The log filename without any date expansion.

See Also: getDatedFilename

getIgnorePaths

public String[] getIgnorePaths()

getLogCookies

public boolean getLogCookies()

Returns: Returns the logCookies.

getLogDateFormat

public String getLogDateFormat()

Returns: The date format to use within the log file.

getLogLatency

public boolean getLogLatency()

Returns: Returns true if logging latency

getLogTimeZone

public 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.

isAppend

public boolean isAppend()

Returns: True if logs are appended to existing log files.

isExtended

public boolean isExtended()

Returns: True if NCSA extended format is to be used.

isStarted

public boolean isStarted()

log

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

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, Writer log)
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: IOException Problem writing log

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

setExtended

public void setExtended(boolean e)

Parameters: e True if NCSA extended format is to be used.

setFilename

public void setFilename(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: NCSARequestLog

setIgnorePaths

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

Parameters: ignorePaths Array of path specifications to ignore

setLogCookies

public void setLogCookies(boolean logCookies)

Parameters: logCookies The logCookies to set.

setLogDateFormat

public void setLogDateFormat(String format)

Parameters: format The date format to use within the log file.

setLogLatency

public void setLogLatency(boolean logLatency)

Parameters: logLatency If true, latency is logged at the end of the log line

setLogTimeZone

public void setLogTimeZone(String tz)

Parameters: tz The date format timezone to use within the log file.

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.

setRetainDays

public void setRetainDays(int retainDays)

Parameters: retainDays The number of days to retain rollovered log files.

start

public void start()

stop

public void stop()
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.