In the end, I got it to work as follows (Eric, probably you meant this when
saying 'pass in something...'):
Auto-configure log4j with the DOMConfigurator.


- Start the EJB server process with -Dlog4j.configuration=log4jEJB.xml

- Have an entity bean implemented like:


public class MyBean implements EntityBean {

    // Upon the following statement, log4j will now auto-configure itself
using file log4jEJB.xml
    // Because it ends with 'xml', the DOMConfigurator will be used
implicitly
    public static Category logger = Category.getInstance("MyCategory");

    public ...ejbCreate(...) {
      logger.info("Do you feel lucky ?");
      ...
...


- Using the Socketserver, this gives a nice result, where my WebServer and
EJB server both log
  their stuff at the same place. I am curious for the log4j RMI Server as
discussed on this list some days ago !


Greeting,

        - Fernand.


-----Original Message-----
From: Pugh, Eric [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 7:29 PM
To: 'LOG4J Users Mailing List'
Subject: RE: Auto-configure log4j ?


So are you saying that if I set it up as a value in my deployment
description, log4j will find it?  That setting things in deployment
descriptiors is the same as setting them up as system properties?

I am in a similar situation where I want to use log4j for my EJB's, but
always have to pass in something to set up the logj path.. 

Eric

-----Original Message-----
From: Paul Glezen [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 19, 2001 12:20 PM
To: LOG4J Users Mailing List
Subject: Re: Auto-configure log4j ?


Hi Ferdinand,

I think you want to take advantage of the static initializer build into
the Category class.  By setting a system property called
"log4j.configuration", you can determine the resource URL that
configures your logging infrastructure.  If this property is not set,
then it looks for log4j.properties somewhere in the classpath.  If you
are using an EJB Server, then setting this property somewhere in the
deployment descriptor should set you up.

This is an important feature for EJB users since in many cases, one is
not sure in what order classes will be instanciated and invoked.

For more information on this log4j bootstrapping process, check out the
Category's javadoc.  In particular, read the information on the
log4j.configuration field.  Grabbing a peak at the static initializer in
the Category.java source code should also make things clear.

Good luck,
- Paul Glezen

> I have a question w.r.t. Configuring (initializing) log4j:
> 
> If I start a Webserver or an EJBServer, I must initialize log4j.
> 
> I can do this 'by hand' (e.g. by writing a servlet that configures log4j
by
> either using BasicConfigurator, DOMConfigurator or PropertyConfigurator).
> 
> Is it also possible to let log4j configure itself automatically upon the
> first category.getInstance()... ? This would save writing the
> 'initialization' in WEBServer or EJBServer.

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

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

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

Reply via email to