Package org.eclipse.jetty.server
Class NCSARequestLog
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.server.AbstractNCSARequestLog
-
- org.eclipse.jetty.server.NCSARequestLog
-
- All Implemented Interfaces:
RequestLog,org.eclipse.jetty.util.component.LifeCycle
- Direct Known Subclasses:
AsyncNCSARequestLog
@ManagedObject("NCSA standard format request log") public class NCSARequestLog extends AbstractNCSARequestLogThisRequestLogimplementation outputs logs in the pseudo-standard NCSA common log format. Configuration options allow a choice between the standard Common Log Format (as used in the 3 log format) and the Combined Log Format (single log format). This log format can be output by most web servers, and almost all web log analysis software can understand these formats.
-
-
Field Summary
-
Fields inherited from class org.eclipse.jetty.server.AbstractNCSARequestLog
LOG
-
-
Constructor Summary
Constructors Constructor Description NCSARequestLog()Create request log object with default settings.NCSARequestLog(String filename)Create request log object with specified output file name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoStart()Set up request logging and open log file.protected voiddoStop()Close the log file and perform cleanup.StringgetDatedFilename()Retrieve the file name of the request log with the expanded date wildcard if the output is written to the disk usingRolloverFileOutputStream.StringgetFilename()Retrieve the output file name of the request log.StringgetFilenameDateFormat()Retrieve the file name date format string.intgetRetainDays()Retrieve the number of days before rotated log files are deleted.booleanisAppend()Retrieve append to log flag.protected booleanisEnabled()Is logging enabledvoidsetAppend(boolean append)Set append to log flag.voidsetFilename(String filename)Set the output file name of the request log.voidsetFilenameDateFormat(String logFileDateFormat)Set the log file name date format.voidsetRetainDays(int retainDays)Set the number of days before rotated log files are deleted.voidwrite(String requestEntry)Write requestEntry out.-
Methods inherited from class org.eclipse.jetty.server.AbstractNCSARequestLog
getAuthentication, getIgnorePaths, getLogCookies, getLogDateFormat, getLogLatency, getLogLocale, getLogServer, getLogTimeZone, getPreferProxiedForAddress, isExtended, isLogDispatch, log, logExtended, setExtended, setIgnorePaths, setLogCookies, setLogDateFormat, setLogDispatch, setLogLatency, setLogLocale, setLogServer, setLogTimeZone, setPreferProxiedForAddress
-
-
-
-
Constructor Detail
-
NCSARequestLog
public NCSARequestLog()
Create request log object with default settings.
-
NCSARequestLog
public NCSARequestLog(String filename)
Create request log object with specified output file name.- Parameters:
filename- the file name for the request log. This may be in the format expected byRolloverFileOutputStream
-
-
Method Detail
-
setFilename
public void setFilename(String filename)
Set the output file name of the request log. The file name may be in the format expected byRolloverFileOutputStream.- Parameters:
filename- file name of the request log
-
getFilename
@ManagedAttribute("file of log") public String getFilename()Retrieve the output file name of the request log.- Returns:
- file name of the request log
-
getDatedFilename
public String getDatedFilename()
Retrieve the file name of the request log with the expanded date wildcard if the output is written to the disk usingRolloverFileOutputStream.- Returns:
- file name of the request log, or null if not applicable
-
isEnabled
protected boolean isEnabled()
Description copied from class:AbstractNCSARequestLogIs logging enabled- Specified by:
isEnabledin classAbstractNCSARequestLog- Returns:
- true if logging is enabled
-
setRetainDays
public void setRetainDays(int retainDays)
Set the number of days before rotated log files are deleted.- Parameters:
retainDays- number of days to keep a log file
-
getRetainDays
@ManagedAttribute("number of days that log files are kept") public int getRetainDays()Retrieve the number of days before rotated log files are deleted.- Returns:
- number of days to keep a log file
-
setAppend
public void setAppend(boolean append)
Set append to log flag.- Parameters:
append- true - request log file will be appended after restart, false - request log file will be overwritten after restart
-
isAppend
@ManagedAttribute("existing log files are appends to the new one") public boolean isAppend()Retrieve append to log flag.- Returns:
- value of the flag
-
setFilenameDateFormat
public void setFilenameDateFormat(String logFileDateFormat)
Set the log file name date format.- Parameters:
logFileDateFormat- format string that is passed toRolloverFileOutputStream- See Also:
RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
-
getFilenameDateFormat
public String getFilenameDateFormat()
Retrieve the file name date format string.- Returns:
- the log File Date Format
-
write
public void write(String requestEntry) throws IOException
Description copied from class:AbstractNCSARequestLogWrite requestEntry out. (to disk or slf4j log)- Specified by:
writein classAbstractNCSARequestLog- Parameters:
requestEntry- the request entry- Throws:
IOException- if unable to write the entry
-
doStart
protected void doStart() throws ExceptionSet up request logging and open log file.- Overrides:
doStartin classAbstractNCSARequestLog- Throws:
Exception- See Also:
AbstractLifeCycle.doStart()
-
doStop
protected void doStop() throws ExceptionClose the log file and perform cleanup.- Overrides:
doStopin classAbstractNCSARequestLog- Throws:
Exception- See Also:
AbstractLifeCycle.doStop()
-
-