gudii9
asked on
java log4j example not working
Hi,
I am running below log4j example.
https://logging.apache.org/log4j/1.2/manual.html
My code looks as below
I am getting lot of compilation errors as i am not able to get references to
import org.apache.log4j.Logger;
and
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConf igurator;
what are jars i need to include to fix these errors.
I am basically using eclipse and created one Dynamic WEb Project(TestLog) and then added above two classes to that project.
I am not sure what all jars i need to add and how to configure them in the eclipse to take effect into the TestLog project. Are there are any better links with more clear detailed description with screenshot on the set up and execution, output.
please advise
Any links resources ideas highly appreciated. Thanks in advance
I am running below log4j example.
https://logging.apache.org/log4j/1.2/manual.html
My code looks as below
package test;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("This is the Test Servlet");
Enumeration headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = (String) headerNames.nextElement();
out.print("<br/>Header Name: <em>" + headerName);
String headerValue = request.getHeader(headerName);
out.print("</em>, Header Value: <em>" + headerValue);
out.println("</em>");
}
}
}
and other class is package com.foo;
import org.apache.log4j.Logger;
public class Bar {
static Logger logger = Logger.getLogger(Bar.class);
public void doIt() {
logger.debug("Did it again!");
}
}
I am getting lot of compilation errors as i am not able to get references to
import org.apache.log4j.Logger;
and
import org.apache.log4j.Logger;
import org.apache.log4j.BasicConf
what are jars i need to include to fix these errors.
I am basically using eclipse and created one Dynamic WEb Project(TestLog) and then added above two classes to that project.
I am not sure what all jars i need to add and how to configure them in the eclipse to take effect into the TestLog project. Are there are any better links with more clear detailed description with screenshot on the set up and execution, output.
please advise
Any links resources ideas highly appreciated. Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.