From: pero Date: Thu, 13 Sep 2007 21:43:22 +0000 (+0000) Subject: Improve large-file support (more then 4 Gb) at all AccessLogValves, backport from... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0b05ebb993a86479c3d6078860ec771f9f573617;p=tomcat7.0 Improve large-file support (more then 4 Gb) at all AccessLogValves, backport from 5.5.25. git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@575475 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/valves/AccessLogValve.java b/java/org/apache/catalina/valves/AccessLogValve.java index 013cc69ad..f0948f4d0 100644 --- a/java/org/apache/catalina/valves/AccessLogValve.java +++ b/java/org/apache/catalina/valves/AccessLogValve.java @@ -1099,7 +1099,7 @@ public class AccessLogValve public void addElement(StringBuffer buf, Date date, Request request, Response response, long time) { - int length = response.getContentCount(); + long length = response.getContentCountLong() ; if (length <= 0 && conversion) { buf.append('-'); } else { diff --git a/java/org/apache/catalina/valves/JDBCAccessLogValve.java b/java/org/apache/catalina/valves/JDBCAccessLogValve.java index b39ea1c1b..df01b4c7e 100644 --- a/java/org/apache/catalina/valves/JDBCAccessLogValve.java +++ b/java/org/apache/catalina/valves/JDBCAccessLogValve.java @@ -45,11 +45,11 @@ import org.apache.catalina.util.StringManager; * To use, copy into the server/classes directory of the Tomcat installation * and configure in server.xml as: *
- * 		<Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
- *        	driverName="your_jdbc_driver"
- *        	connectionURL="your_jdbc_url"
- *        	pattern="combined" resolveHosts="false"
- * 		/>
+ *      <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
+ *          driverName="your_jdbc_driver"
+ *          connectionURL="your_jdbc_url"
+ *          pattern="combined" resolveHosts="false"
+ *      />
  * 
*

*

@@ -93,6 +93,11 @@ import org.apache.catalina.util.StringManager; * INDEX (userAgent) * ); * + *

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 number and other databases use bytes BIGINT NOT NULL. + *

+ * *

* If the table is created as above, its name and the field names don't need * to be defined. @@ -120,21 +125,21 @@ public final class JDBCAccessLogValve * Class constructor. Initializes the fields with the default values. * The defaults are: *

-     * 		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;
      * 
*/ public JDBCAccessLogValve() { @@ -162,7 +167,12 @@ public final class 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. */ @@ -419,6 +429,19 @@ public final class JDBCAccessLogValve 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 @@ -449,7 +472,8 @@ public final class JDBCAccessLogValve 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(); @@ -478,7 +502,14 @@ public final class JDBCAccessLogValve 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 = ""; @@ -508,11 +539,11 @@ public final class JDBCAccessLogValve if (conn != null) close(); } - numberOfTries--; + numberOfTries--; } } - } + } /** @@ -666,7 +697,7 @@ public final class JDBCAccessLogValve started = false; close() ; - + } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index d2a4b3895..31f2217f4 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -27,6 +27,7 @@ Yoav Shapira Filip Hanik Rainer Jung + Peter Rossbach Changelog @@ -74,7 +75,10 @@ Support logging of current thread name at AccessLogValve (ex. add %I to your pattern). Usefull to compare access logging entry later with a stacktraces. (pero) - + + + Improve large-file support (more then 4 Gb) at all AccessLogValves, backport from 5.5.25. (pero) +