/**
+ * enabled this component
+ */
+ protected boolean enabled = true;
+
+ /**
* The pattern used to format our access log lines.
*/
protected String pattern = null;
// ------------------------------------------------------------- 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.
* throwables will be caught and logged.
*/
public void backgroundProcess() {
- if (writer != null && buffered) {
+ if (started && getEnabled() && writer != null && buffered) {
writer.flush();
}
}
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);
}
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"/>
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"/>
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"/>