You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jacob Kjome <ho...@visi.com> on 2002/10/29 17:41:50 UTC

Re[2]: Initializing EJBs

Hello David,

If you want an example of a LoggerRepositorySelector, check out the
one I did in the Barracuda open source presentation layer project.  It
works under Tomcat, but really should work anywhere where there are
separate classloaders for applications.

http://barracuda.enhydra.org/software/cvs/cvsweb.cgi/Projects/EnhydraOrg/toolsTech/Barracuda/src/org/enhydra/barracuda/core/util/logging/

There are 3 components to setting up Log4j in a servlet environment.
Log4jInit is a servlet that initializes Log4j upon application
startup.  Log4jAppliicationWatch is a ServletContextListener that
listens for application shutdown and cleans up log4j loggers and
appenders (like LogManager.shutdown()).  Log4jCRS is a custom contextual
logger repository selector which tracks various logger repositories
being used.  The first 2 classes belong in the WEB-INF/lib or
WEB-INF/classes of the webapp.  The Log4jCRS can be in the webpapp
classloader as long as Log4j.jar exists there also.  If Log4jCRS
exists in a parent classloader, such as $CATALINA_HOME/shared/lib,
you need to make sure that your webapps either contain Log4jCRS and
Log4j.jar in their webapp classloader or remove Log4j.jar from
WEB-INF/lib.  Basically, the one thing you need to make
sure you don't do is put Log4jCRS in a parent classloader and leave
Log4j.jar in the webapp classloader.  You will get all sorts of errors
there.

Anyway, this set up allows me to share one version of Log4j.jar from
$CATALINA_HOME/common/lib and keep each webapp in its own logging
universe via separate logger repositories (hierarchies) keyed by
classloader.

See also the configuration needed in WEB-INF/web.xml and
WEB-INF/log4j.xml.  Just browse through the cvsWeb to find them.

Jake

Monday, October 28, 2002, 1:32:19 PM, you wrote:

LD> Dean,

LD> Thanks for responding.

LD> Our goal is for every application to have its own logging universe (own
LD> logging repository).

LD> Does your solution provide this?
LD> Is log4j-version in your system CP?

LD> I'd be interested in your class, regardless.

LD> Thanks again!

LD> -----Original Message-----
LD> From: Dean McCall [mailto:dmccall@allidex.com]
LD> Sent: Monday, October 28, 2002 2:27 PM
LD> To: Log4J Users List
LD> Subject: RE: Initializing EJBs


LD> David,

LD> We use WebLogic and Log4j.  In WebLogic, you can configure a startup class
LD> that loads when the J2EE server starts.  I developed a class that reads and
LD> watches an xml configuration using the DOMConfigurator.  This configures
LD> Log4j for any component that runs on the server, ie: ejb or servlet.

LD> If you are interested in the class.  Let me know.

LD> Dean


LD> -----Original Message-----
LD> From: Lu, David [mailto:dlu@tiaa-cref.org]
LD> Sent: Monday, October 28, 2002 12:02 PM
LD> To: 'Log4J Users List'
LD> Subject: Initializing EJBs


LD> I've been struggling to find an answer as to how to initialize EJBs.

LD> In log4j documentation, Ceki's book and in TSS, there seems to be no answer
LD> as where to put
LD> DOMConfigure.configure() for EJBs.

LD> We will be using one configuration file per application so that rules out
LD> the default initialization procedure.

LD> We also want to maintain separation of logging configuration so placing the
LD> initialization procedure in a
LD> WebLogic startup class is out of the question since that means log4j will be
LD> in the system cp and therefore override
LD> any log4j in each application archive.

LD> Does anyone have a tested way of initializing EJB's using multiple
LD> configuration files without using the default initialization procedure?


LD> **********************************************************************
LD> This message, including any attachments, contains confidential information
LD> intended for a specific individual and purpose, and is protected by law.  If
LD> you are not the intended recipient, please contact sender immediately by
LD> reply e-mail and destroy all copies.  You are hereby notified that any
LD> disclosure, copying, or distribution of this message, or the taking of any
LD> action based on it, is strictly prohibited.
LD> TIAA-CREF
LD> **********************************************************************

LD> --
LD> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
LD> For additional commands, e-mail: <ma...@jakarta.apache.org>


LD> --
LD> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
LD> For additional commands, e-mail: <ma...@jakarta.apache.org>

LD> --
LD> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
LD> For additional commands, e-mail: <ma...@jakarta.apache.org>



-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>