Log4J is totally independent to Struts. You can use it like you want.
Me, I extend struts ActionSerlvet to initialize Log4J in the init method.
Like that:
public class MyActionServlet extends ActionServlet {
protected static Category log = Category.getInstance(MyActionServlet.class);
public void init () throws ServletException {
// Set up a simple configuration that logs on the console.
String prefix = getServletContext().getRealPath("/");
String file = getInitParameter("log4j-init-file");
// if the log4j-init-file is not set, then no point in trying
if (file != null) {
PropertyConfigurator.configure(prefix + file);
}
// Very important, init the struts ActionServlet
super.init();
}
}
web.xml:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>controller.MyActionServlet</servlet-class>
<init-param>
<param-name>log4j-init-file</param-name>
<param-value>WEB-INF/classes/config_log.properties</param-value>
</init-param>
(...)
</servlet>
--- storck <[EMAIL PROTECTED]> a �crit : > Hi,
>
> I am a very beginner to Log4J and I would like to
> know how to use it in best
> way within Struts?
>
> Any comments are welcome!
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
---------------------------------
Yahoo! Courrier -- Une adresse @yahoo.fr gratuite et en fran�ais !