org.eclipse.jetty.server

## Class NCSARequestLog

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.server.NCSARequestLog

All Implemented Interfaces:
  RequestLog, LifeCycle

    public class NCSARequestLog
    extends AbstractLifeCycle
    implements RequestLog

### Nested Class Summary

### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`AbstractLifeCycle.AbstractLifeCycleListener`

### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

`LifeCycle.Listener`

### Field Summary

### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

### Constructor Summary

Constructors
Constructor and Description
`NCSARequestLog()` Create request log object with default settings.
`NCSARequestLog(String filename)` Create request log object with specified output file name.

### Method Summary

Methods
`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.

### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

`addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

### 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 by `RolloverFileOutputStream`

### 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 by `RolloverFileOutputStream`.

Parameters:
  `filename` - file name of the request log

#### getFilename

    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 using `RolloverFileOutputStream`.

Returns:
  file name of the request log, or null if not applicable

#### setLogDateFormat

    public void setLogDateFormat(String format)

Set the timestamp format for request log entries in the file. If this is not set, the pre-formated request timestamp is used.

Parameters:
  `format` - timestamp format string

#### getLogDateFormat

    public String getLogDateFormat()

Retrieve the timestamp format string for request log entries.

Returns:
  timestamp format string.

#### setLogLocale

    public void setLogLocale(Locale logLocale)

Set the locale of the request log.

Parameters:
  `logLocale` - locale object

#### getLogLocale

    public Locale getLogLocale()

Retrieve the locale of the request log.

Returns:
  locale object

#### setLogTimeZone

    public void setLogTimeZone(String tz)

Set the timezone of the request log.

Parameters:
  `tz` - timezone string

#### getLogTimeZone

    public String getLogTimeZone()

Retrieve the timezone of the request log.

Returns:
  timezone string

#### 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

    public int getRetainDays()

Retrieve the number of days before rotated log files are deleted.

Returns:
  number of days to keep a log file

#### setExtended

    public void setExtended(boolean extended)

Set the extended request log format flag.

Parameters:
  `extended` - true - log the extended request information, false - do not log the extended request information

#### isExtended

    public boolean isExtended()

Retrieve the extended request log format flag.

Returns:
  value of the flag

#### 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

    public boolean isAppend()

Retrieve append to log flag.

Returns:
  value of the flag

#### setIgnorePaths

    public void setIgnorePaths(String[] ignorePaths)

Set request paths that will not be logged.

Parameters:
  `ignorePaths` - array of request paths

#### getIgnorePaths

    public String[] getIgnorePaths()

Retrieve the request paths that will not be logged.

Returns:
  array of request paths

#### setLogCookies

    public void setLogCookies(boolean logCookies)

Controls logging of the request cookies.

Parameters:
  `logCookies` - true - values of request cookies will be logged, false - values of request cookies will not be logged

#### getLogCookies

    public boolean getLogCookies()

Retrieve log cookies flag

Returns:
  value of the flag

#### setLogServer

    public void setLogServer(boolean logServer)

Controls logging of the request hostname.

Parameters:
  `logServer` - true - request hostname will be logged, false - request hostname will not be logged

#### getLogServer

    public boolean getLogServer()

Retrieve log hostname flag.

Returns:
  value of the flag

#### setLogLatency

    public void setLogLatency(boolean logLatency)

Controls logging of request processing time.

Parameters:
  `logLatency` - true - request processing time will be logged false - request processing time will not be logged

#### getLogLatency

    public boolean getLogLatency()

Retrieve log request processing time flag.

Returns:
  value of the flag

#### setPreferProxiedForAddress

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

Parameters:
  `preferProxiedForAddress` - true - IP address from header will be logged, false - IP address from the connection will be logged

#### getPreferProxiedForAddress

    public boolean getPreferProxiedForAddress()

Retrieved log X-Forwarded-For IP address 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 to `RolloverFileOutputStream`
See Also:
  `RolloverFileOutputStream.RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)`

#### getFilenameDateFormat

    public String getFilenameDateFormat()

Retrieve the file name date format string.

Returns:
  the log File Date Format

#### setLogDispatch

    public void setLogDispatch(boolean value)

Controls logging of the request dispatch time

Parameters:
  `value` - true - request dispatch time will be logged false - request dispatch time will not be logged

#### isLogDispatch

    public boolean isLogDispatch()

Retrieve request dispatch time logging flag

Returns:
  value of the flag

#### log

    public void log(Request request,
           Response response)

Writes the request and response information to the output stream.

Specified by:
  `log` in interface `RequestLog`
See Also:
  `RequestLog.log(org.eclipse.jetty.server.Request, org.eclipse.jetty.server.Response)`

#### logExtended

    protected void logExtended(Request request,
                   Response response,
                   StringBuilder b)
                        throws IOException

Writes extended request and response information to the output stream.

Parameters:
  `request` - request object
  `response` - response object
  `b` - StringBuilder to write to
Throws:
  `IOException`

#### doStart

    protected void doStart()
                    throws Exception

Set up request logging and open log file.

Overrides:
  `doStart` in class `AbstractLifeCycle`
Throws:
  `Exception`
See Also:
  `AbstractLifeCycle.doStart()`

#### doStop

    protected void doStop()
                   throws Exception

Close the log file and perform cleanup.

Overrides:
  `doStop` in class `AbstractLifeCycle`
Throws:
  `Exception`
See Also:
  `AbstractLifeCycle.doStop()`