[Geoserver-devel] RequestObjectLogger

Hey Justin, would you mind applying the bellow patch to
RequestObjectLogger in order not to generate too many strings when not
needed? I tested it by switching between geosever_developer and
production logging while running a gwc seed task and it seems it does
its job. The performance penalty for this case is around 3%. Not that a
big deal, but still it'd be good to avoid unnecessary log calls?

Cheers,
Gabriel

--- a/ows/src/main/java/org/geoserver/ows/util/RequestObjectLogger.java
+++ b/ows/src/main/java/org/geoserver/ows/util/RequestObjectLogger.java
@@ -4,6 +4,7 @@
  */
package org.geoserver.ows.util;

+import java.util.logging.Level;
import java.util.logging.Logger;

import org.aopalliance.intercept.MethodInterceptor;
@@ -27,7 +28,9 @@ public class RequestObjectLogger implements
MethodInterceptor {
     }
     
     public Object invoke(MethodInvocation invocation) throws Throwable
{
-
+ if (!logger.isLoggable(Level.INFO)) {
+ return invocation.proceed();
+ }
         StringBuffer log = new StringBuffer();
         log.append("\n" + "Request: " +
invocation.getMethod().getName());

--
Gabriel Roldan
groldan@anonymised.com
Expert service straight from the developers

Looks good. Apply as you like.

On Wed, Apr 6, 2011 at 3:29 PM, Gabriel Roldán <groldan@anonymised.com> wrote:

Hey Justin, would you mind applying the bellow patch to
RequestObjectLogger in order not to generate too many strings when not
needed? I tested it by switching between geosever_developer and
production logging while running a gwc seed task and it seems it does
its job. The performance penalty for this case is around 3%. Not that a
big deal, but still it’d be good to avoid unnecessary log calls?

Cheers,
Gabriel

— a/ows/src/main/java/org/geoserver/ows/util/RequestObjectLogger.java
+++ b/ows/src/main/java/org/geoserver/ows/util/RequestObjectLogger.java
@@ -4,6 +4,7 @@
*/
package org.geoserver.ows.util;

+import java.util.logging.Level;
import java.util.logging.Logger;

import org.aopalliance.intercept.MethodInterceptor;
@@ -27,7 +28,9 @@ public class RequestObjectLogger implements
MethodInterceptor {
}

public Object invoke(MethodInvocation invocation) throws Throwable
{

  • if (!logger.isLoggable(Level.INFO)) {
  • return invocation.proceed();
  • }
    StringBuffer log = new StringBuffer();
    log.append(“\n” + "Request: " +
    invocation.getMethod().getName());


Gabriel Roldan
groldan@anonymised.com
Expert service straight from the developers


Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.