Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging for REST-Requests #186

Closed
schabe77 opened this issue May 3, 2024 · 3 comments
Closed

Logging for REST-Requests #186

schabe77 opened this issue May 3, 2024 · 3 comments

Comments

@schabe77
Copy link

schabe77 commented May 3, 2024

Do you provide a way to log the REST requests like the SOAP logging, which is described here?

As far as I can see it is possible to register a jakarta.ws.rs.client.ClientRequestFilter/jakarta.ws.rs.client.ClientRequestFilter like this one on the javax.ws.rs.client.Client, but I don't see anything like this at HttpClientProvider.

@dennis-yemelyanov
Copy link
Contributor

dennis-yemelyanov commented May 3, 2024

If using CXF, the same logging setting com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump works for both SOAP and REST. But some slf4j implementation needs to be added as well, more details can be found here: Logging service calls

For any custom implementation we can override HttpClientProvider methods like configureClientBuilder() and register LoggingFeature or other filters. An example can be found here: Customizing HTTP client

@schabe77
Copy link
Author

schabe77 commented May 3, 2024

Thank you! With your answer to #184 I managed to integrate a logger:

        GlobalSettings.setHttpClientProvider(new HttpClientProvider() {
            @Override
            protected ClientBuilder configureClientBuilder(ClientBuilder clientBuilder) {
                return super.configureClientBuilder(clientBuilder)
                        .register(org.glassfish.jersey.message.GZipEncoder.class)
                        .register(org.glassfish.jersey.client.filter.EncodingFilter.class)
                        .register(org.glassfish.jersey.logging.LoggingFeature.builder().verbosity(Verbosity.PAYLOAD_ANY).level(Level.FINEST).build());
            }
        });

@schabe77 schabe77 closed this as completed May 3, 2024
@dennis-yemelyanov
Copy link
Contributor

Note, there was also a fix in 13.0.20.1 to call readEntity() instead of getEntity() for synchronous calls (apparently getEntity() doesn't invoke some filters). Asynchronous calls (like the ones made by BulkServiceManager) were not affected (they were using readEntity() already): f2e69d1#diff-270a571915d22522c540a948a1b45939dd42f85b18079b7ae77d110a4289288d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants