View Single Post
  #2 (permalink)  
Old 08-01-2007, 06:31 AM
mary mary is offline
Member
 
Join Date: Jul 2007
Posts: 51
mary is on a distinguished road
I give you an example
Code:
package com.foo; import org.apache.log4j.PropertyConfigurator; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.PrintWriter; import java.io.IOException; public class Log4jInit extends HttpServlet { public void init() { String prefix = getServletContext().getRealPath("/"); String file = getInitParameter("log4j-init-file"); // if the log4j-init-file is not set, then no point in trying if(file != null) { PropertyConfigurator.configure(prefix+file); } } public void doGet(HttpServletRequest req, HttpServletResponse res) { }
if you want more details you can check the documentation of the log4j project
Reply With Quote