Package org.restlet.service
Class LogService
java.lang.Object
org.restlet.service.Service
org.restlet.service.LogService
Service providing access logging service. The implementation is fully based
on the standard logging mechanism introduced in JDK 1.4.
The default access log format follows the W3C Extended Log File Format with the following fields used:
If you use Analog to generate your log reports, and if you use the default log format, then you can simply specify this string as a value of the LOGFORMAT command: (%Y-%m-%d\t%h:%n:%j\t%S\t%u\t%j\t%j\t%j\t%r\t%q\t%c\t%b\t%j\t%T\t%v\t%B\t%f)
For custom access log format, see the syntax to use and the list of available variable names in
The default access log format follows the W3C Extended Log File Format with the following fields used:
- Date (YYYY-MM-DD)
- Time (HH:MM:SS)
- Client address (IP)
- Remote user identifier (see RFC 1413)
- Server address (IP)
- Server port
- Method (GET|POST|...)
- Resource reference path (including the leading slash)
- Resource reference query (excluding the leading question mark)
- Response status code
- Number of bytes sent
- Number of bytes received
- Time to serve the request (in milliseconds)
- Host reference
- Client agent name
- Referrer reference
If you use Analog to generate your log reports, and if you use the default log format, then you can simply specify this string as a value of the LOGFORMAT command: (%Y-%m-%d\t%h:%n:%j\t%S\t%u\t%j\t%j\t%j\t%r\t%q\t%c\t%b\t%j\t%T\t%v\t%B\t%f)
For custom access log format, see the syntax to use and the list of available variable names in
Template. - Author:
- Jerome Louvel
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateInboundFilter(Context context) Create the filter that should be invoked for incoming calls.protected StringgetDefaultResponseLogMessage(Response response, int duration) Format a log entry using the default IIS log format.Returns the URI template of loggable resource references.Returns the name of the JDK's logger to use when logging access calls.Returns the URI reference of the log properties.Returns the format used when logging responses.getResponseLogMessage(Response response, int duration) Format an access log entry.booleanIndicates if the identity check (as specified by RFC1413) is enabled.booleanisLoggable(Request request) Indicates if the call should be logged during the processing chain.voidsetIdentityCheck(boolean identityCheck) Indicates if the identity check (as specified by RFC1413) is enabled.voidsetLoggableTemplate(String loggableTemplateRef) Sets the URI template of loggable resource references.voidsetLoggableTemplate(Template loggableTemplate) Sets the URI template of loggable resource references.voidsetLoggerName(String name) Sets the name of the JDK's logger to use when logging access calls.voidsetLogPropertiesRef(String logPropertiesUri) Sets the URI reference of the log properties.voidsetLogPropertiesRef(Reference logPropertiesRef) Sets the URI reference of the log properties.voidsetResponseLogFormat(String responseLogFormat) Sets the format to use when logging responses.voidstart()Starts the log service by attempting to read the log properties if thegetLogPropertiesRef()returns a non null URI reference.Methods inherited from class org.restlet.service.Service
createOutboundFilter, getContext, isEnabled, isStarted, isStopped, setContext, setEnabled, stop
-
Field Details
-
responseLogTemplate
The response log template to use.
-
-
Constructor Details
-
LogService
public LogService()Constructor. -
LogService
public LogService(boolean enabled) Constructor.- Parameters:
enabled- True if the service has been enabled.
-
-
Method Details
-
createInboundFilter
Description copied from class:ServiceCreate the filter that should be invoked for incoming calls.- Overrides:
createInboundFilterin classService- Parameters:
context- The current context.- Returns:
- The new filter or null.
-
getDefaultResponseLogMessage
Format a log entry using the default IIS log format.- Parameters:
response- The response to log.duration- The call duration (in milliseconds).- Returns:
- The formatted log entry.
-
getLoggableTemplate
Returns the URI template of loggable resource references. Returns null by default, meaning the all requests are loggable, independant of their target resource URI reference.- Returns:
- The URI template of loggable resource references.
- See Also:
-
getLoggerName
Returns the name of the JDK's logger to use when logging access calls. The default name will follow this pattern: "org.restlet.MyComponent.LogService", where "MyComponent" will correspond to the simple class name of your component subclass or to the base "Component" class.- Returns:
- The name of the JDK's logger to use when logging access calls.
-
getLogPropertiesRef
Returns the URI reference of the log properties.- Returns:
- The URI reference of the log properties.
-
getResponseLogFormat
Returns the format used when logging responses.- Returns:
- The format used, or null if the default one is used.
- See Also:
-
getResponseLogMessage
Format an access log entry. If the log template property isn't provided, then a default IIS like format is used.- Parameters:
response- The response to log.duration- The call duration.- Returns:
- The formatted log entry.
-
isIdentityCheck
public boolean isIdentityCheck()Indicates if the identity check (as specified by RFC1413) is enabled. Default value is false.- Returns:
- True if the identity check is enabled.
-
isLoggable
Indicates if the call should be logged during the processing chain. By default, it tries to match the request URI with thegetLoggableTemplate()URI template otherwise is returns true.- Parameters:
request- The request to log.- Returns:
- True if the call should be logged during the processing chain.
-
setIdentityCheck
public void setIdentityCheck(boolean identityCheck) Indicates if the identity check (as specified by RFC1413) is enabled.- Parameters:
identityCheck- True if the identity check is enabled.
-
setLoggableTemplate
Sets the URI template of loggable resource references.- Parameters:
loggableTemplateRef- The URI template of loggable resource references.- See Also:
-
setLoggableTemplate
Sets the URI template of loggable resource references.- Parameters:
loggableTemplate- The URI template of loggable resource references.
-
setLoggerName
Sets the name of the JDK's logger to use when logging access calls.- Parameters:
name- The name of the JDK's logger to use when logging access calls.
-
setLogPropertiesRef
Sets the URI reference of the log properties.- Parameters:
logPropertiesRef- The URI reference of the log properties.
-
setLogPropertiesRef
Sets the URI reference of the log properties.- Parameters:
logPropertiesUri- The URI reference of the log properties.
-
setResponseLogFormat
Sets the format to use when logging responses. The default format matches the one of IIS 6.- Parameters:
responseLogFormat- The format to use when logging responses.- See Also:
-
start
Starts the log service by attempting to read the log properties if thegetLogPropertiesRef()returns a non null URI reference.
-