All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.restlet.service.LogService Maven / Gradle / Ivy

Go to download

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:
*
    *
  1. Date (YYYY-MM-DD)
  2. *
  3. Time (HH:MM:SS)
  4. *
  5. Client address (IP)
  6. *
  7. Remote user identifier (see RFC 1413)
  8. *
  9. Server address (IP)
  10. *
  11. Server port
  12. *
  13. Method (GET|POST|...)
  14. *
  15. Resource reference path (including the leading slash)
  16. *
  17. Resource reference query (excluding the leading question mark)
  18. *
  19. Response status code
  20. *
  21. Number of bytes sent
  22. *
  23. Number of bytes received
  24. *
  25. Time to serve the request (in milliseconds)
  26. *
  27. Host reference
  28. *
  29. Client agent name
  30. *
  31. Referrer reference
  32. *
*
* 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