Re: [Jersey] LoggingFilter

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 15 Feb 2010 17:35:55 +0100

On Feb 15, 2010, at 4:20 PM, Casper Bang wrote:

> Subclass LoggingFilter and check with a regular expression whether to
> log or not? I do a similar thing for caching filter, it feels a little
> AOP like. You could probably take this a step further and create a
> provider such that you can decorate your resources with logging
> annotations.

Yes, you can use your own defined logging annotations on a resource
method if you write a ResourceFilterFactory:

and the request filter sets a property to dynamically enabled/disable
logging of entities per-request if the annotation is present. Then you
could modify LoggingFilter to support this property.

On the small chance you are not aware, but it is possible to disable
logging for all request and response entities:

An alternative is to set a max size of request or response entity to
be written, say up to the first 2Kb of entity are written. This is
really easy to implement.