public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Constructor and Description |
---|
NCSARequestLog()
Create request log object with default settings.
|
NCSARequestLog(String filename)
Create request log object with specified output file name.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doStart()
Set up request logging and open log file.
|
protected void |
doStop()
Close the log file and perform cleanup.
|
String |
getDatedFilename()
Retrieve the file name of the request log with the expanded
date wildcard if the output is written to the disk using
RolloverFileOutputStream . |
String |
getFilename()
Retrieve the output file name of the request log.
|
String |
getFilenameDateFormat()
Retrieve the file name date format string.
|
String[] |
getIgnorePaths()
Retrieve the request paths that will not be logged.
|
boolean |
getLogCookies()
Retrieve log cookies flag
|
String |
getLogDateFormat()
Retrieve the timestamp format string for request log entries.
|
boolean |
getLogLatency()
Retrieve log request processing time flag.
|
Locale |
getLogLocale()
Retrieve the locale of the request log.
|
boolean |
getLogServer()
Retrieve log hostname flag.
|
String |
getLogTimeZone()
Retrieve the timezone of the request log.
|
boolean |
getPreferProxiedForAddress()
Retrieved log X-Forwarded-For IP address flag.
|
int |
getRetainDays()
Retrieve the number of days before rotated log files are deleted.
|
boolean |
isAppend()
Retrieve append to log flag.
|
boolean |
isExtended()
Retrieve the extended request log format flag.
|
boolean |
isLogDispatch()
Retrieve request dispatch time logging flag
|
void |
log(Request request,
Response response)
Writes the request and response information to the output stream.
|
protected void |
logExtended(Request request,
Response response,
StringBuilder b)
Writes extended request and response information to the output stream.
|
void |
setAppend(boolean append)
Set append to log flag.
|
void |
setExtended(boolean extended)
Set the extended request log format flag.
|
void |
setFilename(String filename)
Set the output file name of the request log.
|
void |
setFilenameDateFormat(String logFileDateFormat)
Set the log file name date format.
|
void |
setIgnorePaths(String[] ignorePaths)
Set request paths that will not be logged.
|
void |
setLogCookies(boolean logCookies)
Controls logging of the request cookies.
|
void |
setLogDateFormat(String format)
Set the timestamp format for request log entries in the file.
|
void |
setLogDispatch(boolean value)
Controls logging of the request dispatch time
|
void |
setLogLatency(boolean logLatency)
Controls logging of request processing time.
|
void |
setLogLocale(Locale logLocale)
Set the locale of the request log.
|
void |
setLogServer(boolean logServer)
Controls logging of the request hostname.
|
void |
setLogTimeZone(String tz)
Set the timezone of the request log.
|
void |
setPreferProxiedForAddress(boolean preferProxiedForAddress)
Controls whether the actual IP address of the connection or
the IP address from the X-Forwarded-For header will be logged.
|
void |
setRetainDays(int retainDays)
Set the number of days before rotated log files are deleted.
|
protected void |
write(String log) |
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public NCSARequestLog()
public NCSARequestLog(String filename)
filename
- the file name for the request log.
This may be in the format expected
by RolloverFileOutputStream
public void setFilename(String filename)
RolloverFileOutputStream
.filename
- file name of the request logpublic String getFilename()
public String getDatedFilename()
RolloverFileOutputStream
.public void setLogDateFormat(String format)
format
- timestamp format stringpublic String getLogDateFormat()
public void setLogLocale(Locale logLocale)
logLocale
- locale objectpublic Locale getLogLocale()
public void setLogTimeZone(String tz)
tz
- timezone stringpublic String getLogTimeZone()
public void setRetainDays(int retainDays)
retainDays
- number of days to keep a log filepublic int getRetainDays()
public void setExtended(boolean extended)
extended
- true - log the extended request information,
false - do not log the extended request informationpublic boolean isExtended()
public void setAppend(boolean append)
append
- true - request log file will be appended after restart,
false - request log file will be overwritten after restartpublic boolean isAppend()
public void setIgnorePaths(String[] ignorePaths)
ignorePaths
- array of request pathspublic String[] getIgnorePaths()
public void setLogCookies(boolean logCookies)
logCookies
- true - values of request cookies will be logged,
false - values of request cookies will not be loggedpublic boolean getLogCookies()
public void setLogServer(boolean logServer)
logServer
- true - request hostname will be logged,
false - request hostname will not be loggedpublic boolean getLogServer()
public void setLogLatency(boolean logLatency)
logLatency
- true - request processing time will be logged
false - request processing time will not be loggedpublic boolean getLogLatency()
public void setPreferProxiedForAddress(boolean preferProxiedForAddress)
preferProxiedForAddress
- true - IP address from header will be logged,
false - IP address from the connection will be loggedpublic boolean getPreferProxiedForAddress()
public void setFilenameDateFormat(String logFileDateFormat)
logFileDateFormat
- format string that is passed to RolloverFileOutputStream
RolloverFileOutputStream.RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
public String getFilenameDateFormat()
public void setLogDispatch(boolean value)
value
- true - request dispatch time will be logged
false - request dispatch time will not be loggedpublic boolean isLogDispatch()
public void log(Request request, Response response)
log
in interface RequestLog
RequestLog.log(org.eclipse.jetty.server.Request, org.eclipse.jetty.server.Response)
protected void write(String log) throws IOException
IOException
protected void logExtended(Request request, Response response, StringBuilder b) throws IOException
request
- request objectresponse
- response objectb
- StringBuilder to write toIOException
protected void doStart() throws Exception
doStart
in class AbstractLifeCycle
Exception
AbstractLifeCycle.doStart()
protected void doStop() throws Exception
doStop
in class AbstractLifeCycle
Exception
AbstractLifeCycle.doStop()
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.