I'm using Servlet
based web application and want to have proper logging support. I'm using Log4j
and when I do receive any requests I want to log it with it's whole properties.
For example:
@WebServlet(name = "Login", value = "/Login")
public class Login extends HttpServlet {
final static Logger logger = Logger.getLogger(Login.class);
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.info(req); // I want to log request with its
// properties: such as request parameters, headers and so on
// TODO some logic here
}
}
So, how can I mange to override somehow HttpServletRequest
s toString()
method which actually is an interface. Is it good idea to create Wrapper
class for it and there I can override toString()
method ?
Aucun commentaire:
Enregistrer un commentaire