I see a problem with this with respect to log rotation. The way things work now, on every request tomcat checks to see if the log needs rotated. (It actually checks at most, once a second).

The way it determines to rotate the log is via the date format. Since the date format is hardcoded to contain just the day information - this is ok. But if a user defines a log date format containing the second (or even worse, the millisecond), then the logs would rotate every second. Which some may consider a feature :)


-Tim


Michael Heinrichs wrote:
Much of the access log filename can be customized in the Valve
declaration using prefix and suffix, but the date format used for
the filename is hardcoded in the Valve code.

Here's a patch that allows the date format to be specified in
the Valve definition alongside prefix and suffix.

If this patch is accepted, I can put together another patch for
the admin webapp.

See patch below.

Mike Heinrichs



Index: AccessLogValve.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/valves/AccessLogValve.java,v
retrieving revision 1.15
diff -u -r1.15 AccessLogValve.java
--- AccessLogValve.java 22 Nov 2002 20:27:12 -0000 1.15
+++ AccessLogValve.java 15 Jan 2003 19:19:32 -0000
@@ -325,6 +325,11 @@
private long rotationLastChecked = 0L;


+ /**
+ * The access log filename date format
+ */
+ private String dateFormat = "yyyy-MM-dd";
+
// ------------------------------------------------------------- Properties


@@ -443,6 +448,28 @@


/**
+ * Return the date format string used for access log filenames
+ */
+ public String getDateFormat() {
+
+ return (dateFormat);
+
+ }
+
+
+ /**
+ * Set the date format string used for access log filenames
+ *
+ * @param dateFormat The new date format
+ */
+ public void setDateFormat(String dateFormat) {
+
+ this.dateFormat = dateFormat;
+
+ }
+
+
+ /**
* Return the log file suffix.
*/
public String getSuffix() {
@@ -1024,7 +1051,7 @@
if (timeZone.length() < 5)
timeZone = timeZone.substring(0, 1) + "0" +
timeZone.substring(1, timeZone.length());
- dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
+ dateFormatter = new SimpleDateFormat(this.dateFormat);
dateFormatter.setTimeZone(tz);
dayFormatter = new SimpleDateFormat("dd");
dayFormatter.setTimeZone(tz);


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to