• 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

Where to put log4j.properties?

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it ok to put log4j.properties under WEB-INF/  ?  I tiried and it seems ok but  I saw some people put it under WEB-INF/classes...  Where should it be put ?  Thanks
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say it's fine to put it wherever it is working.

As long as it is somewhere under WEB-INF it cannot be served via URL and is secure (or at least as secure as anything else under WEB-INF).
 
Saloon Keeper
Posts: 21135
134
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Log4j looks for the log4j.properties and/or log4j.xml files in the application classpath. So you would put it in WEB-INF/classes. Because it has no package pedigree, it goes directly in the classes/ directory, not in some subdirectory of classes.

That's the default, of course. If you have custom log4j initialization code, you can make it pull from any resource location in the WAR, but that's usually not worth it. You could also put logj.properties somewhere completely outside the webapp server and WAR altogether if you wanted to be able to customize logging externally. In which case I recommend that you should use an absolute filesystem path to point to the file. And if you really want to get fancy and be OS-independent, define that filesystem path as a JNDI property as part of the application deployment.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The file should be located in the WEB-INF/classes directory. This directory structure should be packaged within the war file.
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!