You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2010/05/03 14:28:25 UTC

How to implement custom RequestLogger / RequestLoggerService?

Hi,

I'd like to implement a custom request logging service that outputs
something like:

<request duration>#<http method>#<resource path>#<value of "foo"
request parameter>#

just on request exit, in a parsable format, for performance analysis purposes.

But neither RequestLoggerService nor RequestLogger [1] implement
public interfaces, so they don't seem to be replaceable.

Is that by design?

Otherwise I can add public interfaces that both of those implement, to
make it possible to customize/replace them.

-Bertrand

[1] http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/log/

Re: How to implement custom RequestLogger / RequestLoggerService?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, May 3, 2010 at 2:46 PM, Carsten Ziegeler <cz...@apache.org> wrote:
> What about a servlet filter?

Yes, that would work of course - I was wondering how that could be
done within Sling.

In the meantime Felix mentioned that additional RequestLoggerService
instances can be created via factory configurations, so if you're
using jcrinstall for example adding a configuration node like

"org.apache.sling.engine.impl.log.RequestLoggerService-combined": {
     "request.log.service.output": "../logs/combinedrequest.log",
     "request.log.service.outputtype": 1,
     "request.log.service.onentry": false,
     "request.log.service.format": "%t [%R] %m %U%q %H %s
%{Content-Type}o %D %b",
     "jcr:createdBy": "admin",
     "jcr:created": "Tue Apr 27 2010 13:51:37 GMT+0200",
     "jcr:primaryType": "sling:OsgiConfig"
   }

will create an additional request exit logger.

The log format string is based on the httpd mod_log_config,
http://httpd.apache.org/docs/2.1/mod/mod_log_config.html, though not
all flags are supported.

Logging of parameter values is not currently supported, but logging of
the complete query string is.

-Bertrand

Re: How to implement custom RequestLogger / RequestLoggerService?

Posted by Carsten Ziegeler <cz...@apache.org>.
What about a servlet filter?

Carsten

Bertrand Delacretaz  wrote
> Hi,
> 
> I'd like to implement a custom request logging service that outputs
> something like:
> 
> <request duration>#<http method>#<resource path>#<value of "foo"
> request parameter>#
> 
> just on request exit, in a parsable format, for performance analysis purposes.
> 
> But neither RequestLoggerService nor RequestLogger [1] implement
> public interfaces, so they don't seem to be replaceable.
> 
> Is that by design?
> 
> Otherwise I can add public interfaces that both of those implement, to
> make it possible to customize/replace them.
> 
> -Bertrand
> 
> [1] http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/impl/log/
> 


-- 
Carsten Ziegeler
cziegeler@apache.org