> So, when using a J2EE server, where is the appropriate place for putting
> the configure call?

If think I've found a simple solution which works fine with all EJB
containers, without using servlets or JSPs and, AFAIK, without violating
the specs.
It also works if different JVMs are forked.
I've already tested it with J2EE RI, JBoss, and iPAS with no problems.
Basicly I get categories via a simple support class which automatically
configures logging.
Here it is:

---BEGIN-CUT---
import org.apache.tools.log4j.Category;

public class LoggerFactory {

    private static boolean configured = false;

    private static void configure() {
        if (!configured) {
            /*** Place all your configuration stuff here. ***/
            configured = true;
        }
    }

    public static Category getInstance(Class c) {
        configure();
        return Category.getInstance(c);
    }

    public static Category getInstance(String s) {
        configure();
        return Category.getInstance(s);
    }

}
---END-CUT---

Each time I need a Category in my EJBs I call LoggerFactory.getInstance.
If it's the first time I do so in the current JVM, configuration takes
place.
The only cost you pay is an "if" for each category instantiation (i.e.
tipically only once per class).

Hope it helps.
Let me know what you think about it...



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

Reply via email to