hstaudacher / osgi-jax-rs-connector

An OSGi - JAX-RS 2.0 Connector, software repository available on the link below
http://hstaudacher.github.io/osgi-jax-rs-connector
Other
190 stars 98 forks source link

How to configure logging for jersey requests #35

Closed sschober closed 10 years ago

sschober commented 10 years ago

This might be not related to this project, but I'm trying to debug why a POST-Request (GET works like charm) produces an internal server error.

All I see on my Equinix OSGi console is:

Dez 17, 2013 2:29:17 PM org.glassfish.jersey.server.ApplicationHandler initialize
Information: Initiating Jersey application, version Jersey: 2.3.1 2013-09-27 07:50:09...
Dez 17, 2013 2:29:17 PM org.glassfish.jersey.server.ApplicationHandler initialize
Information: Initiating Jersey application, version Jersey: 2.3.1 2013-09-27 07:50:09...

But I'd like to get some Information about request routing, deserialization errors, etc.

I tried including the org.apache.log4j bundle that comes with Eclise 4.3.1, but won't get any more detailed messages.

Are there any properties I need to set?

My client code looks like this:

    public <T extends Traceroute>  boolean upload(TracerouteResult<T> trace ){
        Trace trc = Trace.fromTracerouteResult(trace);
        WebTarget wtrg = _c.target(URL);
        Response res= wtrg
        .request(MediaType.APPLICATION_XML)
        .cookie(new Cookie("user", USER))
        .cookie(new Cookie("auth", AUTH))
        .post(Entity.entity(trc, MediaType.APPLICATION_XML));
        System.err.println(res.toString());     
        return true;
    }

Trace is an XmlRootElement:

@XmlRootElement
public class Trace {
    private Map<Integer,List<String>> addressesPerHop;
    private String source;
    private String traget;
        /* ... */
}

My server-side method like this;

    @POST
    @Path("paths")
    @RolesAllowed("pobe")
    @Consumes(MediaType.APPLICATION_XML)
    public void addTrace( Trace trace, @Context HttpServletResponse res) {
            System.err.println("Got trace from: " + trace.getSource());
                        ...
        }
sschober commented 10 years ago

Figured it out myself: https://gist.github.com/sschober/8020297 - Maybe not the most elegant way of doing this?