Author: pero Date: Mon Apr 23 07:17:49 2007 New Revision: 531475 URL: http://svn.apache.org/viewvc?view=rev&rev=531475 Log: add enabled attribute to support JMX enable/disable logging.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/mbeans-descriptors.xml tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java?view=diff&rev=531475&r1=531474&r2=531475 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/AccessLogValve.java Mon Apr 23 07:17:49 2007 @@ -158,6 +158,11 @@ /** + * enabled this component + */ + protected boolean enabled = true; + + /** * The pattern used to format our access log lines. */ protected String pattern = null; @@ -312,6 +317,20 @@ // ------------------------------------------------------------- Properties + /** + * @return Returns the enabled. + */ + public boolean getEnabled() { + return enabled; + } + + /** + * @param enabled + * The enabled to set. + */ + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } /** * Return the directory in which we create log files. @@ -519,7 +538,7 @@ * throwables will be caught and logged. */ public void backgroundProcess() { - if (writer != null && buffered) { + if (started && getEnabled() && writer != null && buffered) { writer.flush(); } } @@ -537,27 +556,30 @@ public void invoke(Request request, Response response) throws IOException, ServletException { - // Pass this request on to the next valve in our pipeline - long t1 = System.currentTimeMillis(); - - getNext().invoke(request, response); - - long t2 = System.currentTimeMillis(); - long time = t2 - t1; - - if (logElements == null || condition != null - && null != request.getRequest().getAttribute(condition)) { - return; - } - - Date date = getDate(); - StringBuffer result = new StringBuffer(); - - for (int i = 0; i < logElements.length; i++) { - logElements[i].addElement(result, date, request, response, time); - } - - log(result.toString()); + if (started && getEnabled()) { + // Pass this request on to the next valve in our pipeline + long t1 = System.currentTimeMillis(); + + getNext().invoke(request, response); + + long t2 = System.currentTimeMillis(); + long time = t2 - t1; + + if (logElements == null || condition != null + && null != request.getRequest().getAttribute(condition)) { + return; + } + + Date date = getDate(); + StringBuffer result = new StringBuffer(); + + for (int i = 0; i < logElements.length; i++) { + logElements[i].addElement(result, date, request, response, time); + } + + log(result.toString()); + } else + getNext().invoke(request, response); } Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/mbeans-descriptors.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/mbeans-descriptors.xml?view=diff&rev=531475&r1=531474&r2=531475 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/mbeans-descriptors.xml (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/valves/mbeans-descriptors.xml Mon Apr 23 07:17:49 2007 @@ -17,6 +17,11 @@ type="java.lang.String" writeable="false"/> + <attribute name="enabled" + description="Enable Access Logging" + is="true" + type="boolean"/> + <attribute name="containerName" description="Object name of the container" type="javax.management.ObjectName"/> @@ -109,6 +114,11 @@ type="java.lang.String" writeable="false"/> + <attribute name="enabled" + description="Enable Access Logging" + is="true" + type="boolean"/> + <attribute name="containerName" description="Object name of the container" type="javax.management.ObjectName"/> @@ -173,6 +183,11 @@ description="Fully qualified class name of the managed object" type="java.lang.String" writeable="false"/> + + <attribute name="enabled" + description="Enable Access Logging" + is="true" + type="boolean"/> <attribute name="containerName" description="Object name of the container" Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?view=diff&rev=531475&r1=531474&r2=531475 ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Mon Apr 23 07:17:49 2007 @@ -28,6 +28,9 @@ <bug>41655</bug> Fix message translations. Japanese translations provided by Suzuki Yuichiro. (markt) </fix> + <add> + Add enabled attribute to AccessLogValve (pero) + </add> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]