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.

2 Answers 2

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.

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;
   }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.