Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Log4J - reading properties file from /WEB-INF directory issue..

490060Sep 1 2006 — edited Sep 4 2006
I'm just learning to implement Log4J; the approach I am taking for my JSF application running under Tomcat 5.5x is to create an initialization servlet to initialize the logger, and then access the logger instance within my backing beans and application module services. I include log4j.jar file in /WEB-INF/lib and log4j.properties in /WEB-INF.

First I wanted to see if this was a good approach, and secondly I'm having trouble accessing the log4j.properties file from the /WEB-INF directory (see below) - any suggestions on how to set up the path so that the properties file can be found (I receive a java.io.filenotfoundexception)?

Where I'm looking for direction is how to define a single instance of the logger and then access that instance from my java classes versus re-creating the logger in each class.

----- web.xml --------
<servlet>
<servlet-name>LogServlet</servlet-name>
<servlet-class>com.sidehire.view.util.LogServlet</servlet-class>
<init-param>
<param-name>setup</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

------ LogServlet class ------
public void init()
throws ServletException {
String config = getInitParameter("setup");
PropertyConfigurator.configure(config);
}

Thanks

Message was edited by:
javaX
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2006
Added on Sep 1 2006
2 comments
698 views