You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by AndyG <an...@orprovision.com> on 2011/12/06 14:36:58 UTC

Logging broken?

Does anyone know what has changed on the logging front to break logging -
Using standalone server. Does not even create the 'openejb.log' anymore?

--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-broken-tp4164685p4164685.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: Logging broken?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
+1 for me

- Romain


2011/12/6 AndyG <an...@orprovision.com>

> Checked in a fix. Please have a look and make sure I have not broken
> something you intended.
>
> I think that the order of the day is:
>
> 1. Check for and use a user specified factory,
> 2. Else, check for log4j and configure if not overridden,
> 3. Else, check for JUL and configure if not overridden,
> 4. Check for slf4j and use,
> 5. Else use either log4j or JUL.
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-broken-tp4164685p4165079.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: Logging broken?

Posted by AndyG <an...@orprovision.com>.
Checked in a fix. Please have a look and make sure I have not broken
something you intended.

I think that the order of the day is:

1. Check for and use a user specified factory,
2. Else, check for log4j and configure if not overridden,
3. Else, check for JUL and configure if not overridden,
4. Check for slf4j and use,
5. Else use either log4j or JUL.

--
View this message in context: http://openejb.979440.n4.nabble.com/Logging-broken-tp4164685p4165079.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: Logging broken?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

i changed Logger class:

public static void configure() {
        String factoryName = System.getProperty("openejb.log.factory");
        Class<?> factoryClass = null;
        if (factoryName != null) {
            ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
            if (classLoader != null) {
                try {
                    factoryClass = classLoader.loadClass(factoryName);
                } catch (ClassNotFoundException e) {
                }
            }

            if (factoryClass == null) {
                try {
                    factoryClass = Class.forName(factoryName);
                } catch (ClassNotFoundException e) {
                }
            }
        }

        LogStreamFactory factory = null;
        if (factoryClass != null) {
            try {
                factory = (LogStreamFactory) factoryClass.newInstance();
            } catch (Exception e) {
            }
        }

        // slf4j
        if (factory == null) {
            try {
                // ensure Log4j is in the CP

Logger.class.getClassLoader().loadClass("org.slf4j.LoggerFactory");
                if
(!System.getProperties().containsKey("org.apache.cxf.Logger")) {
                    System.setProperty("org.apache.cxf.Logger",
"org.apache.cxf.common.logging.Slf4jLogger");
                }
                factory = new Slf4jLogStreamFactory();
            } catch (NoClassDefFoundError e) {
                // slf4j not in classpath
            } catch (ClassNotFoundException cnfe) {
                // idem
            }
        }

        // Log4j is possible
        if (factory == null) {
            try {
                // ensure Log4j is in the CP

Logger.class.getClassLoader().loadClass("org.apache.log4j.Layout");
                if
(!System.getProperties().containsKey("org.apache.cxf.Logger")) {
                    System.setProperty("org.apache.cxf.Logger",
"org.apache.cxf.common.logging.Log4jLogger");
                }
                factory = new Log4jLogStreamFactory();
            } catch (NoClassDefFoundError e) {
                //log4j not in classpath
            } catch (ClassNotFoundException cnfe) {
                // idem
            }
        }

        // else JUL
        if (factory == null) {
            factory = new JuliLogStreamFactory();
        }

        logStreamFactory = factory;
    }



- Romain


2011/12/6 AndyG <an...@orprovision.com>

> Does anyone know what has changed on the logging front to break logging -
> Using standalone server. Does not even create the 'openejb.log' anymore?
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Logging-broken-tp4164685p4164685.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>