dcsimg

How can I write to a log file from a servlet?

Alex Chaffee

Look for the method ServletContext.log(String) or GenericServlet.log(String). These will write to a servlet log file maintained by your servlet container.

E.g.:

  log("Servlet called with name " + request.getParameter("name"));

If this is insufficient, you can use java.io classes to write your own files.

See also: