org.restlet.engine.log

## Class LogFilter

- java.lang.Object
- - org.restlet.Restlet
  - - org.restlet.routing.Filter
    - - org.restlet.engine.log.LogFilter

All Implemented Interfaces:
  Uniform

    public class LogFilter
    extends Filter

Filter logging all calls after their handling by the target Restlet. The current format is similar to IIS 6 logs. The logging is based on the java.util.logging package. Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.

Author:
  Jerome Louvel

### Field Summary

Fields
`protected LogService` `logService` The log service.
`protected Template` `logTemplate` The log template to use.

### Fields inherited from class org.restlet.routing.Filter

`CONTINUE, SKIP, STOP`

### Constructor Summary

Constructors
Constructor and Description
`LogFilter(Context context, LogService logService)` Constructor.

### Method Summary

Methods
`protected void` `afterHandle(Request request, Response response)` Allows filtering after processing by the next Restlet.
`protected int` `beforeHandle(Request request, Response response)` Allows filtering before processing by the next Restlet.
`protected java.lang.String` `format(Request request, Response response)` Format a log entry.
`protected java.lang.String` `formatDefault(Request request, Response response, int duration)` Format a log entry using the default format.

### Methods inherited from class org.restlet.routing.Filter

`doHandle, getNext, handle, hasNext, setNext, setNext, start, stop`

### Methods inherited from class org.restlet.Restlet

`finalize, getApplication, getAuthor, getContext, getDescription, getLogger, getName, getOwner, isStarted, isStopped, setAuthor, setContext, setDescription, setName, setOwner`

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

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

### Field Detail

#### logService

    protected volatile LogService logService

The log service.

#### logTemplate

    protected volatile Template logTemplate

The log template to use.

### Constructor Detail

#### LogFilter

    public LogFilter(Context context,
             LogService logService)

Constructor.

Parameters:
  `context` - The context.
  `logService` - The log service descriptor.

### Method Detail

#### afterHandle

    protected void afterHandle(Request request,
                   Response response)

Allows filtering after processing by the next Restlet. Logs the call.

Overrides:
  `afterHandle` in class `Filter`
Parameters:
  `request` - The request to handle.
  `response` - The response to update.

#### beforeHandle

    protected int beforeHandle(Request request,
                   Response response)

Allows filtering before processing by the next Restlet. Saves the start time.

Overrides:
  `beforeHandle` in class `Filter`
Parameters:
  `request` - The request to handle.
  `response` - The response to update.
Returns:
  The continuation status.

#### format

    protected java.lang.String format(Request request,
                          Response response)

Format a log entry.

Parameters:
  `request` - The request to log.
  `response` - The response to log.
Returns:
  The formatted log entry.

#### formatDefault

    protected java.lang.String formatDefault(Request request,
                                 Response response,
                                 int duration)

Format a log entry using the default format.

Parameters:
  `request` - The request to log.
  `response` - The response to log.
  `duration` - The call duration (in milliseconds).
Returns:
  The formatted log entry.