org.restlet.service.LogService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.apache.servicemix.bundles.restlet
Show all versions of org.apache.servicemix.bundles.restlet
This OSGi bundle wraps org.restlet, and com.noelios.restlet ${pkgVersion} jar files.
The newest version!
/**
* Copyright 2005-2008 Noelios Technologies.
*
* The contents of this file are subject to the terms of the following open
* source licenses: LGPL 3.0 or LGPL 2.1 or CDDL 1.0 (the "Licenses"). You can
* select the license that you prefer but you may not use this file except in
* compliance with one of these Licenses.
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.gnu.org/licenses/lgpl-3.0.html
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.sun.com/cddl/cddl.html
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royaltee free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.noelios.com/products/restlet-engine
*
* Restlet is a registered trademark of Noelios Technologies.
*/
package org.restlet.service;
/**
* 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:
*
* - 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 {@link org.restlet.util.Template}.
*
* @see Tutorial: Access logging
* @see Wiki: Logging
* @see java.util.logging
* @author Jerome Louvel
*/
public class LogService extends Service {
/** The access logger name. */
private volatile String loggerName;
/** The log entry format. */
private volatile String logFormat;
/** Indicates if the identity check (as specified by RFC1413) is enabled. */
private volatile boolean identityCheck;
/**
* Constructor.
*
* @param enabled
* True if the service has been enabled.
*/
public LogService(boolean enabled) {
super(enabled);
this.loggerName = null;
this.logFormat = null;
this.identityCheck = false;
}
/**
* Returns the format used.
*
* @return The format used, or null if the default one is used.
* @see org.restlet.util.Template for format syntax and variables.
*/
public String getLogFormat() {
return this.logFormat;
}
/**
* 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.
*
* @return The name of the JDK's logger to use when logging access calls.
*/
public String getLoggerName() {
return this.loggerName;
}
/**
* Indicates if the identity check (as specified by RFC1413) is enabled.
* Default value is false.
*
* @return True if the identity check is enabled.
*/
public boolean isIdentityCheck() {
return this.identityCheck;
}
/**
* Indicates if the identity check (as specified by RFC1413) is enabled.
*
* @param identityCheck
* True if the identity check is enabled.
*/
public void setIdentityCheck(boolean identityCheck) {
this.identityCheck = identityCheck;
}
/**
* Sets the format to use when logging calls. The default format matches the
* one of IIS 6.
*
* @param format
* The format to use when loggin calls.
* @see org.restlet.util.Template for format syntax and variables.
*/
public void setLogFormat(String format) {
this.logFormat = format;
}
/**
* Sets the name of the JDK's logger to use when logging access calls.
*
* @param name
* The name of the JDK's logger to use when logging access calls.
*/
public void setLoggerName(String name) {
this.loggerName = name;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy