01: /*
02: * Copyright 2005-2007 Noelios Consulting.
03: *
04: * The contents of this file are subject to the terms of the Common Development
05: * and Distribution License (the "License"). You may not use this file except in
06: * compliance with the License.
07: *
08: * You can obtain a copy of the license at
09: * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
10: * language governing permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL HEADER in each file and
13: * include the License file at http://www.opensource.org/licenses/cddl1.txt If
14: * applicable, add the following below this CDDL HEADER, with the fields
15: * enclosed by brackets "[]" replaced with your own identifying information:
16: * Portions Copyright [yyyy] [name of copyright owner]
17: */
18:
19: package com.noelios.restlet.util;
20:
21: import java.util.logging.Handler;
22:
23: import com.noelios.restlet.Engine;
24:
25: /**
26: * Access log record formatter which writes a header describing the default log
27: * format.
28: *
29: * @author Jerome Louvel (contact@noelios.com)
30: */
31: public class DefaultAccessLogFormatter extends AccessLogFormatter {
32:
33: @Override
34: public String getHead(Handler h) {
35: StringBuilder sb = new StringBuilder();
36: sb.append("#Software: Noelios Restlet Engine ").append(
37: Engine.VERSION).append('\n');
38: sb.append("#Version: 1.0\n");
39: sb.append("#Date: ");
40: long currentTime = System.currentTimeMillis();
41: sb.append(String.format("%tF", currentTime));
42: sb.append(' ');
43: sb.append(String.format("%tT", currentTime));
44: sb.append('\n');
45: sb.append("#Fields: ");
46: sb.append("date time c-ip cs-username s-ip s-port cs-method ");
47: sb
48: .append("cs-uri-stem cs-uri-query sc-status sc-bytes cs-bytes ");
49: sb.append("time-taken cs-host cs(User-Agent) cs(Referrer)\n");
50: return sb.toString();
51: }
52:
53: }
|