0

I use Restlet with Jetty8. The Jetty log all incoming calls. I want to log all response data also, url and body. Where is the best place to put the log code?

I thought createOutboundRoot is the place but I didn't figured out how to use it and couldn’t find any examples in the web.

ZAky
  • 1,209
  • 8
  • 22

2 Answers2

0

I have never tried it but I would start with a Custom filter and override After handle, this appears to be the way Restlet itself does logging internally see the class LogFilter.

Caleryn
  • 1,084
  • 3
  • 18
  • 23
0

implements a log filter like this :

public class CustomLogFilter extends Filter {



public CustomLogFilter() {
    super();
}

protected int beforeHandle(Request request, Response response) {
    int returned = super.beforeHandle(request, response);
    // Do specific log if needed
    return returned;
}


protected void afterHandle(Request request, Response response) {
    super.afterHandle(request, response);
    // Do specific log if needed
}

}

and use it in your createInboundRoot if you have an Application object :

   public synchronized Restlet createInboundRoot() {
          final Router router = new Router(getContext());
          CustomLogFilter filter = new CustomLogFilter();
          filter.setNext(router);
          return filter;
   }
gartcimore
  • 43
  • 9