Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

log4j.properties file : where to place it in Netbeans

 
Ranch Hand
Posts: 96
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

folderStructure_location.jpg
[Thumbnail for folderStructure_location.jpg]
folderStructure_netbeans.jpg
[Thumbnail for folderStructure_netbeans.jpg]
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
log4j.jpg
[Thumbnail for log4j.jpg]
 
rubbery bacon. rubbery tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!