Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use log4j to save the output to a file
    primarykey
    data
    text
    <p>I have downloaded the log4j jar. But dont know how to use it to save the output to a text file. My code is:</p> <pre><code>import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; public class ShowHeaders extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; String headerName; String headerValue; public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/plain"); PrintWriter out = response.getWriter(); String method= request.getMethod(); out.println("Request Method: " +method); out.println("-----------------------"); String uri= request.getRequestURI(); out.println("URI: " +uri); out.println("-----------------------"); out.println("Request Headers"); Enumeration&lt;?&gt; Enumeration = (java.util.Enumeration&lt;?&gt;) request.getHeaderNames(); while (Enumeration.hasMoreElements()) { String headerName = (String) Enumeration.nextElement(); String headerValue = request.getHeader(headerName); out.print(""+headerName + ": "); out.println(headerValue + ""); } } </code></pre> <p>Kindly tell me where to describe the file location &amp; what to use instead of out.println(); to display it that text file</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload