I have a jsp/servlet application and I am trying to use log4j for logging purpose. Can someone tell me how can I set-up log4j to work in my application. I have log4j.jar in the path , have custom class to logging i.e.
But I can't figure out where and how I instantiate this class,
and where should I put log4j.properties file so I can read it and pass it to this custom class and start the logging. Any help is appreciated.
Thanks
Code:
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import org.apache.log4j.*;
public class Logging
{
private Logging logr = Logger.getLogger(this.getClass().getName());
public Logging(String name)
{
try
{
File file = new File(name);
URL lurl = file.toURL() ;
PropertyConfigurator.configure(lurl);
}
catch (Exception ex)
{
}
}
public void debug (String msg)
{
logger.debug( msg );
}
..................................
But I can't figure out where and how I instantiate this class,
and where should I put log4j.properties file so I can read it and pass it to this custom class and start the logging. Any help is appreciated.
Thanks