aspose file tools*
The moose likes Other Open Source Projects and the fly likes log4j.properties file : where to place it in Netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "log4j.properties file : where to place it in Netbeans" Watch "log4j.properties file : where to place it in Netbeans" New topic
Author

log4j.properties file : where to place it in Netbeans

Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
Hi All,

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



[Thumbnail for folderStructure_location.jpg]

[Thumbnail for folderStructure_netbeans.jpg]

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

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.
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
Hi Paul,
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.


[Thumbnail for log4j.jpg]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: log4j.properties file : where to place it in Netbeans