log4j.properties file : where to place it in Netbeans
Joined: Apr 05, 2010
I guess this is a very common issue, but all solutions/suggestions provided for, in different forums did not work for me. So I am posting this for any help. I just started learning log4j and am working on implementing it in my tutorial project. I wrote the log4j.properties file, which looks like this :
I am using logging in an action class in my Struts project. this is the code :
When I am trying to run this from Netbean 7.0 IDE, I'm getting an error
SEVERE: log4j:WARN No appenders could be found for logger (org.apache.struts.faces.application.ActionListenerImpl).
SEVERE: log4j:WARN Please initialize the log4j system properly.
SEVERE: log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I gather from all the discussions that this means my log4j.properties file is not available. I have already tried placing it in the src folder as well as in WEB-INF under web folder. It still doesn't work.
Can anyone please advise where to place it? My folder structure from netbeans looks like the attached file folderStructure_netbeans, while the folder structure at the physical location looks like shown in folderStructure_location. Netbeans is using Glassfish server 3.1
The short answer is that it should go in a folder which is in the classpath. In a web application, then the WEB-INF/classes folder would be a good choice.
And since you're developing a web application, you should ask where to put it in a web application. Don't put it somewhere else for Netbeans's purposes, if you do then the web application will only work when run from Netbeans.
Joined: Apr 05, 2010
By WEB-INF/classes, I guess you mean the folder structure that is created when the application is built and deployed? In my case, netbeans is creating this structure inside the build folder, that gets created when I build the application from inside netbeans. And this folder does have a copy of my properties file. But it still doesn't work. If you mean some other place, can you kindly clarify further?
I have attached the screenshot to show where I have placed the properties file.