0

I would like to log all HTTP request in Jetty, which is well documented, but I can;t find any resources how can I mask some of the arguments.

E.g.:

json/users/detail?id=dsgrw543

should be logged as:

json/users/detail?id=********

or similar.

The main motivation is that I could give those logs for analytics, without worries that privacy of our users could be compromised. Ideally on-line, without using batch processing or other script.

Please note, that I use other authentication mechanism (cookies/all write methods are POST/etc.) and I can't change the existing URLs.

So far my only idea is to implement it as a class on top of NCSARequestLog: http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/NCSARequestLog.html

What are the better ways of doing that?

Jakozaur
  • 1,957
  • 3
  • 18
  • 20
  • Do you want to eliminate query string completely? Or just mask the values? – Nishant Mar 08 '13 at 08:37
  • Just mask it value or eliminate that argument. I would like to keep query string. Even just throwing everything away after ? is fine for me. – Jakozaur Mar 08 '13 at 08:40

1 Answers1

0

you may write a simple util like this, use it wherever you are logging

    Enumeration<String> s = request.getParameterNames();
    String q = "";
    while(s.hasMoreElements()){
        q += s.nextElement() + "=***&";
    }
    String url = request.getServletPath()+(q.length()>0?"?"+q:"");

or may be request.getRequestedURI() in place of getServletPath

Nishant
  • 54,584
  • 13
  • 112
  • 127