I am trying to configure log4j for one of my web projects. For that I want to read the log4j.properties file. Below is the code
private URL url;
private File file;
file = new File(url.getPath());
DOMConfigurator.configure(url);
Following is the error
Exception in thread "Thread-1" java.lang.NullPointerException
Then I try to give path of where to file is located to the url command
private URL url= new URL("file:/E:/work/workspace/dvddao/WEB-INF/classes/log4j.properties");
private File file;
file = new File(url.getPath());
DOMConfigurator.configure(url);
This time I get MalformedURLException compile error
Default constructor cannot handle exception type MalformedURLException thrown by implicit super constructor. Must define an explicit constructor
Anybody can please give a solution to this. Or an alternate solution to get the url for a properties file