users@glassfish.java.net

Re: Log4j

From: <glassfish_at_javadesktop.org>
Date: Thu, 03 Jan 2008 11:15:28 PST

You can configure Log4J for each GF domain
putting log4j.jar in domains/domain1/lib/ext and log4j.xml in domains/domain1/config
using follow properties in domain.xml

<java-config ...
...
<jvm-options>-Dlog4j.configuration=file:${com.sun.aas.instanceRoot}/config/log4j.xml</jvm-options>
<jvm-options>-Dlog4j.configuratorClass=org.apache.log4j.xml.DOMConfigurator</jvm-options>
...
</java-config>


Using this configuration, you don´t need to put LOG4J in your application classpath, neither configure using listener or othre stuff, you just need to reference the Logger Category in your java classes, like folow section:

public class MyClass {

    // atributo do logger do log4j
    private static Logger logger;
    
    // inicialização do Log4J
    static {
        try {
            logger = Logger.getLogger( MyClass.class );
        } catch (Exception e) {
            e.printStackTrace( System.err );
        }
    }

}

Good luck!
[Message sent by forum member 'ozielneto' (ozielneto)]

http://forums.java.net/jive/thread.jspa?messageID=252155