简体   繁体   中英

Jersey logging request body in tomcat

I am having issues getting the request body xml/json logged by jersey. I have added

    </init-param>
    <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
        <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
    </init-param>
    <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>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.filter.LoggingFilter</param-value>
    </init-param>

in web.xml. I see as below

INFO: 5 * LoggingFilter - Request received on thread catalina-exec-677
5 > POST http://testserver:61001/test-8.1.0.0-SNAPSHOT/des/v1
5 > accept-encoding: gzip,deflate
5 > content-type: application/json
5 > content-length: 1504
5 > host: dimw-desproxy101:61001
5 > connection: Keep-Alive
5 > user-agent: Apache-HttpClient/4.1.1 (java 1.5)

Dec 04, 2013 7:44:49 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 5 * LoggingFilter - Response received on thread catalina-exec-677
5 < 200
5 < Content-Type: application/xml

but not the request body

See https://java.net/jira/browse/JERSEY-749?focusedCommentId=366719&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_366719

Resolving as won't fix as this seems to be only related to Tomcat and there is a known workaround. I believe entity logging is needed for debug purpose only, and there the workaround should not hurt. Please re-open, if you have strong objections.

The workaround provided is to use the HttpNioProtocol connector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM