Quantcast

LoggingFilter

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

LoggingFilter

Ricardo Borillo Domenech
Hi all,

I have a JAX-RS server webapp with LogginFilter enabled in the web.xml:

    <init-param>
      <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
      <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
    </init-param>

I have one method that generates too much log information because of
the type of response ...
Is it possible to disable logging for an specific method?

Thanks in advance.

---
Regards,
====================================
Ricardo Borillo Domenech
http://xml-utils.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LoggingFilter

Casper Bang-2
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.

/Casper

Ricardo Borillo wrote:

> Hi all,
>
> I have a JAX-RS server webapp with LogginFilter enabled in the web.xml:
>
>     <init-param>
>       <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>       <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>     </init-param>
>
> I have one method that generates too much log information because of
> the type of response ...
> Is it possible to disable logging for an specific method?
>
> Thanks in advance.
>
> ---
> Regards,
> ====================================
> Ricardo Borillo Domenech
> http://xml-utils.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LoggingFilter

Paul Sandoz
Administrator

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.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: LoggingFilter

Ricardo Borillo-3
Nice!! This approach seems very usefull ...

Thank you a lot for the information provided :)

---
Salut,
====================================
Ricardo Borillo Domenech
http://xml-utils.com



On Mon, Feb 15, 2010 at 17:35, Paul Sandoz <[hidden email]> wrote:

>
> 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.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...