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:
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/package-summary.html
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:
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
#FEATURE_LOGGING_DISABLE_ENTITY
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.
Paul.