1

How to print the XML response generated from jersey? I need to log the response for info. Is this possible? My service class looks like this:

@Path("/name")
public class AuditoriumService {

  @GET
  @Produces(MediaType.APPLICATION_XML)
  public List<String> getNames() throws UnrecoverableException {
    List<String> nameList = getNameList();
    
    log.info("Response: Status Code: "+200);
    return nameList;
   }
}
Vishwa Dany
  • 327
  • 2
  • 16
  • Why not print the list? If not then look at marshaller and unmarshaller that you may have specified or if using JAXB then use the method provided for the same. – SMA Jan 23 '16 at 13:49
  • You have to use a [LoggingFilter](http://stackoverflow.com/a/2362106/1252603). – Baderous Jan 23 '16 at 14:00
  • Also you could take a look to [this](http://stackoverflow.com/questions/34850858/log-jersey-entity-as-json-as-response/34854130). Uses `LoggingFilter` and `Json`, but you should be able to do something similar. – lrnzcig Jan 24 '16 at 11:00

0 Answers0