* To use, copy into the server/classes directory of the Tomcat installation
* and configure in server.xml as:
* <pre>
- * <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
- * driverName="<i>your_jdbc_driver</i>"
- * connectionURL="<i>your_jdbc_url</i>"
- * pattern="combined" resolveHosts="false"
- * />
+ * <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
+ * driverName="<i>your_jdbc_driver</i>"
+ * connectionURL="<i>your_jdbc_url</i>"
+ * pattern="combined" resolveHosts="false"
+ * />
* </pre>
* </p>
* <p>
* INDEX (userAgent)
* );
* </pre>
+ * <p>Set JDBCAccessLogValve attribute useLongContentLength="true" as you have more then 4GB outputs.
+ * Please, use long SQL datatype at access.bytes attribute.
+ * The datatype of bytes at oracle is <i>number</i> and other databases use <i>bytes BIGINT NOT NULL</i>.
+ * </p>
+ *
* <p>
* If the table is created as above, its name and the field names don't need
* to be defined.
* Class constructor. Initializes the fields with the default values.
* The defaults are:
* <pre>
- * driverName = null;
- * connectionURL = null;
- * tableName = "access";
- * remoteHostField = "remoteHost";
- * userField = "userName";
- * timestampField = "timestamp";
- * virtualHostField = "virtualHost";
- * methodField = "method";
- * queryField = "query";
- * statusField = "status";
- * bytesField = "bytes";
- * refererField = "referer";
- * userAgentField = "userAgent";
- * pattern = "common";
- * resolveHosts = false;
+ * driverName = null;
+ * connectionURL = null;
+ * tableName = "access";
+ * remoteHostField = "remoteHost";
+ * userField = "userName";
+ * timestampField = "timestamp";
+ * virtualHostField = "virtualHost";
+ * methodField = "method";
+ * queryField = "query";
+ * statusField = "status";
+ * bytesField = "bytes";
+ * refererField = "referer";
+ * userAgentField = "userAgent";
+ * pattern = "common";
+ * resolveHosts = false;
* </pre>
*/
public JDBCAccessLogValve() {
// ----------------------------------------------------- Instance Variables
-
+ /**
+ * Use long contentLength as you have more 4 GB output.
+ * @since 6.0.15
+ */
+ protected boolean useLongContentLength = false ;
+
/**
* The connection username to use when trying to connect to the database.
*/
this.resolveHosts = new Boolean(resolveHosts).booleanValue();
}
+ /**
+ * get useLongContentLength
+ */
+ public boolean getUseLongContentLength() {
+ return this.useLongContentLength ;
+ }
+
+ /**
+ * @param useLongContentLength the useLongContentLength to set
+ */
+ public void setUseLongContentLength(boolean useLongContentLength) {
+ this.useLongContentLength = useLongContentLength;
+ }
// --------------------------------------------------------- Public Methods
String query="";
if(request != null)
query = request.getRequestURI();
- int bytes = response.getContentCount();
+
+ long bytes = response.getContentCountLong() ;
if(bytes < 0)
bytes = 0;
int status = response.getStatus();
ps.setTimestamp(3, new Timestamp(getCurrentTimeMillis()));
ps.setString(4, query);
ps.setInt(5, status);
- ps.setInt(6, bytes);
+
+ if(useLongContentLength) {
+ ps.setLong(6, bytes);
+ } else {
+ if (bytes > Integer.MAX_VALUE)
+ bytes = -1 ;
+ ps.setInt(6, (int) bytes);
+ }
if (pattern.equals("combined")) {
String virtualHost = "";
if (conn != null)
close();
}
- numberOfTries--;
+ numberOfTries--;
}
}
- }
+ }
/**
started = false;
close() ;
-
+
}