Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where to put log4j.properties file in visual web jsf

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,

I have used log4j in several projects just by putting log4j.properties in my default source package.
This time i am using below command (I am using netbeabs ide 6.5.1)



This time the server is saying "java.io.FileNotFoundException: log4j.properties (No such file or directory)"

I have tried default package , root folder , and the web pages folder.

What do you think would be the problem ?

Thanks

 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, what does the java doc for that method say? Where does it start looking for that resource from?
 
baran tamer
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you mean this one

As of log4j version 0.8.5, at class initialization time class, the file log4j.properties will be searched from the search path used to load classes. If the file can be found, then it will be fed to the configure(java.net.URL) method.



I am guessing this is used for initialization, and looking for log4j.properties in the classpath.
But i am trying to override that config file by using



and javadoc doesnt say how PropertyConfigurator.configure behaves
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, I'm not 100% familiar with this, but have you tried placing it in the WEB-INF/classes directory?
 
baran tamer
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have solved it by putting the file in the working config directory at that moment.

which is home/glassfish-v2.1/domains/domain1/config for glassfish.

If mine was a java application it would have worked as i wrote above , however in a web application that is runnning on glassfish you either have to put the properties file in

home/glassfish-v2.1/domains/domain1/config

or give the full path to the function
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think whatever the App server we use, the log4j.properties file for any application should be inside the directory structure of that application.
Like if we have a webapplication then as Martijn said , the best location would be "WEB-INF\classes". It might be the way we load the properties file that would cause the problem of not finding the log4j.properties file.
I faced this problem couple of times but resolved it using

inside ServletContextListener.
getResourceAsStream() looks for the file in classpath and hence can find one if put in "WEB-INF\classes" directory.
 
reply
    Bookmark Topic Watch Topic
  • New Topic