annotate src/org/eclipse/jetty/server/NCSARequestLog.java @ 853:3242aff51053

remove RolloverFileOutputStream and cleanup NCSARequestLog
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 20 Sep 2016 00:23:56 -0600
parents 175577dab6d8
children 359012f4e797
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 // ------------------------------------------------------------------------
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 // All rights reserved. This program and the accompanying materials
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 // are made available under the terms of the Eclipse Public License v1.0
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 // and Apache License v2.0 which accompanies this distribution.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 // The Eclipse Public License is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 // http://www.eclipse.org/legal/epl-v10.html
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 // The Apache License v2.0 is available at
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 // http://www.opensource.org/licenses/apache2.0.php
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 // You may elect to redistribute this code under either of these licenses.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 // ========================================================================
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 //
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 package org.eclipse.jetty.server;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 import java.io.IOException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import java.io.OutputStream;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 import java.io.OutputStreamWriter;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.io.Writer;
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
25 import java.io.File;
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
26 import java.io.FileOutputStream;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 import java.util.Locale;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import java.util.TimeZone;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 import javax.servlet.http.Cookie;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.http.HttpHeaders;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.util.DateCache;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.util.component.AbstractLifeCycle;
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
35 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
36 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 * This {@link RequestLog} implementation outputs logs in the pseudo-standard
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 * NCSA common log format. Configuration options allow a choice between the
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 * standard Common Log Format (as used in the 3 log format) and the Combined Log
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 * Format (single log format). This log format can be output by most web
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 * servers, and almost all web log analysis software can understand these
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 * formats.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 * @org.apache.xbean.XBean element="ncsaLog"
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 /**
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 public class NCSARequestLog extends AbstractLifeCycle implements RequestLog
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
54 private static final Logger LOG = LoggerFactory.getLogger(NCSARequestLog.class);
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
55 private static final String __LINE_SEPARATOR=
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
56 System.getProperty("line.separator","\n");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
58 private String _filename;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
59 private boolean _extended;
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
60 public long sizeLimit = 1048576L;
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
61 private boolean _closeOut;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
62 private boolean _preferProxiedForAddress;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
63 private String _logDateFormat = "dd/MMM/yyyy:HH:mm:ss Z";
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
64 private Locale _logLocale = Locale.getDefault();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
65 private String _logTimeZone = "GMT";
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
66 private boolean _logLatency = false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
67 private boolean _logCookies = false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
68 private boolean _logServer = false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
69 private boolean _logDispatch = false;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
70
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
71 private transient OutputStream _out;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
72 private transient DateCache _logDateCache;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
73 private transient Writer _writer;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
74
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
75 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
76 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
77 * Create request log object with default settings.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
78 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
79 public NCSARequestLog()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
81 _extended = true;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
82 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
83
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
84 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
85 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 * Create request log object with specified output file name.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 * @param filename the file name for the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 * This may be in the format expected
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 * by {@link RolloverFileOutputStream}
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
91 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
92 public NCSARequestLog(String filename)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
93 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
94 _extended = true;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
95 setFilename(filename);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
96 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
97
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
98 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
99 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
100 * Set the output file name of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
101 * The file name may be in the format expected by
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 * {@link RolloverFileOutputStream}.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
103 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
104 * @param filename file name of the request log
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
106 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
107 public void setFilename(String filename)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
108 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
109 if (filename != null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
111 filename = filename.trim();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
112 if (filename.length() == 0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
113 filename = null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
114 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
115 _filename = filename;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
116 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
117
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
118 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 * Retrieve the output file name of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 * @return file name of the request log
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
124 public String getFilename()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
126 return _filename;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
127 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
128
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
129 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
130 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
131 * Set the timestamp format for request log entries in the file.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
132 * If this is not set, the pre-formated request timestamp is used.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
133 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
134 * @param format timestamp format string
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
135 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 public void setLogDateFormat(String format)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
137 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 _logDateFormat = format;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
140
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
141 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
142 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 * Retrieve the timestamp format string for request log entries.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
145 * @return timestamp format string.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
146 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
147 public String getLogDateFormat()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
149 return _logDateFormat;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
151
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
152 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 * Set the locale of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 * @param logLocale locale object
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 public void setLogLocale(Locale logLocale)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
159 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 _logLocale = logLocale;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
162
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
163 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
164 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
165 * Retrieve the locale of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
166 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 * @return locale object
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
168 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 public Locale getLogLocale()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
170 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
171 return _logLocale;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
172 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
173
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
175 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
176 * Set the timezone of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 * @param tz timezone string
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180 public void setLogTimeZone(String tz)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
182 _logTimeZone = tz;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
183 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
184
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
185 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 * Retrieve the timezone of the request log.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 * @return timezone string
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
190 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
191 public String getLogTimeZone()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
192 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
193 return _logTimeZone;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
194 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
195
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
196 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
197 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
198 * Set the extended request log format flag.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
199 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
200 * @param extended true - log the extended request information,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
201 * false - do not log the extended request information
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
202 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
203 public void setExtended(boolean extended)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
204 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
205 _extended = extended;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
206 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
207
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
208 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
209 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
210 * Retrieve the extended request log format flag.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
211 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
212 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
213 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
214 public boolean isExtended()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
215 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
216 return _extended;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
217 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
218
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
219 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
220 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
221 * Controls logging of the request cookies.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
222 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
223 * @param logCookies true - values of request cookies will be logged,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
224 * false - values of request cookies will not be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
225 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
226 public void setLogCookies(boolean logCookies)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
227 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
228 _logCookies = logCookies;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
229 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
230
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
231 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
232 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
233 * Retrieve log cookies flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
234 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
235 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
236 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
237 public boolean getLogCookies()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
238 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
239 return _logCookies;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
240 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
241
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
242 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
243 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
244 * Controls logging of the request hostname.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
245 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
246 * @param logServer true - request hostname will be logged,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
247 * false - request hostname will not be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
248 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
249 public void setLogServer(boolean logServer)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
250 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
251 _logServer = logServer;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
252 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
253
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
254 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
255 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
256 * Retrieve log hostname flag.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
257 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
258 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
259 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
260 public boolean getLogServer()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
261 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
262 return _logServer;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
263 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
264
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
265 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
266 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
267 * Controls logging of request processing time.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
268 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
269 * @param logLatency true - request processing time will be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
270 * false - request processing time will not be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
271 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
272 public void setLogLatency(boolean logLatency)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
273 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
274 _logLatency = logLatency;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
275 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
276
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
277 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
278 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
279 * Retrieve log request processing time flag.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
280 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
281 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
282 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
283 public boolean getLogLatency()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
284 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
285 return _logLatency;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
286 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
287
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
288 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
289 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
290 * Controls whether the actual IP address of the connection or
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
291 * the IP address from the X-Forwarded-For header will be logged.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
292 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
293 * @param preferProxiedForAddress true - IP address from header will be logged,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
294 * false - IP address from the connection will be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
295 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
296 public void setPreferProxiedForAddress(boolean preferProxiedForAddress)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
297 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
298 _preferProxiedForAddress = preferProxiedForAddress;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
299 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
300
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
301 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
302 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
303 * Retrieved log X-Forwarded-For IP address flag.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
304 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
305 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
306 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
307 public boolean getPreferProxiedForAddress()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
308 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
309 return _preferProxiedForAddress;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
310 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
311
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
312 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
313 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
314 * Controls logging of the request dispatch time
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
315 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
316 * @param value true - request dispatch time will be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
317 * false - request dispatch time will not be logged
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
318 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
319 public void setLogDispatch(boolean value)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
320 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
321 _logDispatch = value;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
322 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
323
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
324 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
325 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
326 * Retrieve request dispatch time logging flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
327 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
328 * @return value of the flag
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
329 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
330 public boolean isLogDispatch()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
331 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
332 return _logDispatch;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
333 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
334
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
335 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
336 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
337 * Writes the request and response information to the output stream.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
338 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
339 * @see org.eclipse.jetty.server.RequestLog#log(org.eclipse.jetty.server.Request, org.eclipse.jetty.server.Response)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
340 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
341 public void log(Request request, Response response)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
342 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
343 try
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
344 {
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
345 if (_out == null)
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
346 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
347
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
348 StringBuilder buf = new StringBuilder(256);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
349
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
350 if (_logServer)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
351 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
352 buf.append(request.getServerName());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
353 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
354 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
355
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
356 String addr = null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
357 if (_preferProxiedForAddress)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
358 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
359 addr = request.getHeader(HttpHeaders.X_FORWARDED_FOR);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
360 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
361
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
362 if (addr == null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
363 addr = request.getRemoteAddr();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
364
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
365 buf.append(addr);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
366 buf.append(" - ");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
367
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
368 buf.append(" [");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
369 if (_logDateCache != null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
370 buf.append(_logDateCache.format(request.getTimeStamp()));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
371 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
372 buf.append(request.getTimeStampBuffer().toString());
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
373
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
374 buf.append("] \"");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
375 buf.append(request.getMethod());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
376 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
377 buf.append(request.getUri().toString());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
378 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
379 buf.append(request.getProtocol());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
380 buf.append("\" ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
381 if (request.getAsyncContinuation().isInitial())
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
382 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
383 int status = response.getStatus();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
384 if (status <= 0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
385 status = 404;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
386 buf.append((char)('0' + ((status / 100) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
387 buf.append((char)('0' + ((status / 10) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
388 buf.append((char)('0' + (status % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
389 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
390 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
391 buf.append("Async");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
392
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
393 long responseLength = response.getContentCount();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
394 if (responseLength >= 0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
395 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
396 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
397 if (responseLength > 99999)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
398 buf.append(responseLength);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
399 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
400 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
401 if (responseLength > 9999)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
402 buf.append((char)('0' + ((responseLength / 10000) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
403 if (responseLength > 999)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
404 buf.append((char)('0' + ((responseLength / 1000) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
405 if (responseLength > 99)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
406 buf.append((char)('0' + ((responseLength / 100) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
407 if (responseLength > 9)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
408 buf.append((char)('0' + ((responseLength / 10) % 10)));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
409 buf.append((char)('0' + (responseLength) % 10));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
410 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
411 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
412 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
413 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
414 buf.append(" - ");
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
415
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
416
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
417 if (_extended)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
418 logExtended(request, response, buf);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
419
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
420 if (_logCookies)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
421 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
422 Cookie[] cookies = request.getCookies();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
423 if (cookies == null || cookies.length == 0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
424 buf.append(" -");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
425 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
426 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
427 buf.append(" \"");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
428 for (int i = 0; i < cookies.length; i++)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
429 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
430 if (i != 0)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
431 buf.append(';');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
432 buf.append(cookies[i].getName());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
433 buf.append('=');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
434 buf.append(cookies[i].getValue());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
435 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
436 buf.append('\"');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
437 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
438 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
439
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
440 if (_logDispatch || _logLatency)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
441 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
442 long now = System.currentTimeMillis();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
443
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
444 if (_logDispatch)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
445 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
446 long d = request.getDispatchTime();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
447 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
448 buf.append(now - (d==0 ? request.getTimeStamp():d));
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
449 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
450
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
451 if (_logLatency)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
452 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
453 buf.append(' ');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
454 buf.append(now - request.getTimeStamp());
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
455 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
456 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
457
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
458 buf.append(__LINE_SEPARATOR);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
459
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
460 String log = buf.toString();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
461 write(log);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
462 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
463 catch (IOException e)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
464 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
465 LOG.warn("",e);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
466 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
467 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
468
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
469 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
470 protected void write(String log) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
471 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
472 synchronized(this)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
473 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
474 if (_writer==null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
475 return;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
476 _writer.write(log);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
477 _writer.flush();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
478 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
479 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
480
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
481
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
482 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
483 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
484 * Writes extended request and response information to the output stream.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
485 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
486 * @param request request object
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
487 * @param response response object
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
488 * @param b StringBuilder to write to
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
489 * @throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
490 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
491 protected void logExtended(Request request,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
492 Response response,
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
493 StringBuilder b) throws IOException
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
494 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
495 String referer = request.getHeader(HttpHeaders.REFERER);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
496 if (referer == null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
497 b.append("\"-\" ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
498 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
499 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
500 b.append('"');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
501 b.append(referer);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
502 b.append("\" ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
503 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
504
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
505 String agent = request.getHeader(HttpHeaders.USER_AGENT);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
506 if (agent == null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
507 b.append("\"-\" ");
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
508 else
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
509 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
510 b.append('"');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
511 b.append(agent);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
512 b.append('"');
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
513 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
514 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
515
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
516 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
517 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
518 * Set up request logging and open log file.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
519 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
520 * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
521 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
522 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
523 protected synchronized void doStart() throws Exception
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
524 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
525 if (_logDateFormat != null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
526 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
527 _logDateCache = new DateCache(_logDateFormat,_logLocale);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
528 _logDateCache.setTimeZoneID(_logTimeZone);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
529 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
530
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
531 if (_filename != null) {
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
532 File file = new File(_filename);
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
533 if( file.exists() && file.length() > sizeLimit ) {
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
534 File old = new File(_filename+".old");
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
535 old.delete();
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
536 file.renameTo(old);
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
537 }
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
538 _out = new FileOutputStream(file,true);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
539 _closeOut = true;
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
540 LOG.info("Opened " + _filename);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
541 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
542 else
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
543 _out = System.err;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
544
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
545 synchronized(this)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
546 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
547 _writer = new OutputStreamWriter(_out);
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
548 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
549 super.doStart();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
550 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
551
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
552 /* ------------------------------------------------------------ */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
553 /**
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
554 * Close the log file and perform cleanup.
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
555 *
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
556 * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
557 */
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
558 @Override
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
559 protected void doStop() throws Exception
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
560 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
561 synchronized (this)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
562 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
563 super.doStop();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
564 try
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
565 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
566 if (_writer != null)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
567 _writer.flush();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
568 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
569 catch (IOException e)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
570 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
571 LOG.trace("",e);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
572 }
853
3242aff51053 remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents: 834
diff changeset
573 if (_closeOut)
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
574 try
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
575 {
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
576 _out.close();
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
577 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
578 catch (IOException e)
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
579 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 815
diff changeset
580 LOG.trace("",e);
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
581 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
582
813
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
583 _out = null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
584 _closeOut = false;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
585 _logDateCache = null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
586 _writer = null;
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
587 }
f8f7cb485c25 remove UserIdentity
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
588 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
589 }