Maybe you can configure your log4j with xml files and initialize the log4j
configurator with a ClassLoader as it is explained in the documentation.
I'm sure you need some servlets for your EJBs ?

Initialization servlet
It is also possible to use a special servlet for log4j initialization. Here
is an example,
package com.foo;[PARA][PARA]import
org.apache.log4j.PropertyConfigurator;[PARA]import
javax.servlet.http.HttpServlet;[PARA]import
javax.servlet.http.HttpServletRequest;[PARA]import
javax.servlet.http.HttpServletResponse;[PARA]import
java.io.PrintWriter;[PARA]import java.io.IOException;[PARA][PARA]public
class Log4jInit extends HttpServlet {[PARA][PARA]  public[PARA]  void init()
{[PARA]    String prefix =  getServletContext().getRealPath("/");[PARA]
String file = getInitParameter("log4j-init-file");[PARA]    // if the
log4j-init-file is not set, then no point in trying[PARA]    if(file !=
null) {[PARA]

PropertyConfigurator.configure(prefix+file);[PARA]    }[PARA]  }[PARA][PARA]
public[PARA]  void doGet(HttpServletRequest req, HttpServletResponse res)
{[PARA]  }[PARA]}
Define the following servlet in the web.xml file for your web-application.
  <servlet>[PARA]    <servlet-name>log4j-init</servlet-name>[PARA]
<servlet-class>com.foo.Log4jInit</servlet-class>[PARA][PARA]
<init-param>[PARA]      <param-name>log4j-init-file</param-name>[PARA]
<param-value>WEB-INF/classes/log4j.lcf</param-value>[PARA]
</init-param>[PARA][PARA]    <load-on-startup>1</load-on-startup>[PARA]
</servlet>
Writing an initialization servlet is the most flexible way for initializing
log4j. There are no constraints on the code you can place in the init()
method of the servlet.



Christophe Marcourt
Mondeca
Ingénieur R&D
3, Cité Nollez. 75018 Paris
Phone : +33 1 44 92 35 03
Mobile : +33 6 14 48 65 66
Fax : +33 1 44 92 02 59
http://www.mondeca.com/fr
ICQ : #119811844

-----Message d'origine-----
De : Follender, Ivan (HBO) [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 19 novembre 2002 17:47
À : '[EMAIL PROTECTED]'
Objet : Log4J in EJBs

Hi-

I want to use Log4J in my EJBs.
The guidance I've been getting is that EJBs should not access system files
(e.g. log4j.properties).

Is there a recommended mechanism for configuring the LogFactory for EJBs?

Thanks,
ivan.

============================================================================
==
This e-mail is intended only for the use of the addressees.  Any copying,
forwarding, printing or other use of this e-mail by persons other than the
addressees is not authorized.  This e-mail may contain information that is
privileged, confidential and exempt from disclosure.  If you are not the
intended recipient, please notify us immediately by return e-mail (including
the original message in your reply) and then delete and discard all copies
of the e-mail.  Thank you.




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to