You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2009/10/27 16:54:52 UTC

CXF logging....

As everyone is probably aware, CXF uses the j.u.l API for all of it's logging.   
That's really not likely to change, but we do allow logging to Log4J by 
setting some system properties or a file in META-INF/cxf.    

However,   I was thinking it might make sense to try and detect where SLF4J is 
logging and if it's logging to Log4J, we should as well.    The reflection 
code to do that isn't very complex:

Class.forName("org/slf4j/impl/StaticLoggerBinder");
Class<?> cls = Class.forName("org.slf4j.LoggerFactory");
Class<?> fcls = cls.getMethod("getILoggerFactory").invoke(null).getClass();
if (fcls.getName().contains("Log4j")) {
    cname = "org.apache.cxf.common.logging.Log4jLogger";
} else if (fcls.getName().contains("JCL")) {
    cls = Class.forName("org.apache.commons.logging.LogFactory");
    fcls = cls.getMethod("getFactory").invoke(null).getClass();
    if (fcls.getName().contains("Log4j")) {
        cname = "org.apache.cxf.common.logging.Log4jLogger";
    }
}

What are peoples thoughts on doing that?  That way, if SLF4J is logging to 
Log4J, or if SLF4J is logging to JCL which is logging to Log4J, we would log 
to Log4J as well.    If SLF4J is logging to someplace else, we'd still log to 
j.u.l so that wouldn't change.  

One note: with PAX logging in servicemix/felix, the ILoggerFactory would not 
contain "Log4j".  Thus, we'd continue to use j.u.l.  But that is OK as PAX 
logging already interceptor j.u.l and directs them to the same place.

Thoughts?  Comments?

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: CXF logging....

Posted by Daniel Kulp <dk...@apache.org>.
On Tue October 27 2009 1:10:36 pm Benson Margulies wrote:
> Why not just switch to sfl4j, defaulting to the j.u.l module?

Cause that's a TON of work.   All logging in CXF would need to change.  Plus, 
SLF4J is not i18n enabled at all.   Thus, all the places we use the 
Message.properties files for logging messages would need to be updated to 
handle the i18n stuff themselves instead of letting the logger do it. 

We could wrapper a SLF4J logger with a j.u.l Logger API like we do for Log4J, 
but that seems kind of silly to do j.u.l -> SLF4J -> j.u.l. 

Dan



> 
> On Tue, Oct 27, 2009 at 11:54 AM, Daniel Kulp <dk...@apache.org> wrote:
> > As everyone is probably aware, CXF uses the j.u.l API for all of it's
> > logging.
> > That's really not likely to change, but we do allow logging to Log4J by
> > setting some system properties or a file in META-INF/cxf.
> >
> > However,   I was thinking it might make sense to try and detect where
> > SLF4J is
> > logging and if it's logging to Log4J, we should as well.    The
> > reflection code to do that isn't very complex:
> >
> > Class.forName("org/slf4j/impl/StaticLoggerBinder");
> > Class<?> cls = Class.forName("org.slf4j.LoggerFactory");
> > Class<?> fcls =
> > cls.getMethod("getILoggerFactory").invoke(null).getClass(); if
> > (fcls.getName().contains("Log4j")) {
> >    cname = "org.apache.cxf.common.logging.Log4jLogger";
> > } else if (fcls.getName().contains("JCL")) {
> >    cls = Class.forName("org.apache.commons.logging.LogFactory");
> >    fcls = cls.getMethod("getFactory").invoke(null).getClass();
> >    if (fcls.getName().contains("Log4j")) {
> >        cname = "org.apache.cxf.common.logging.Log4jLogger";
> >    }
> > }
> >
> > What are peoples thoughts on doing that?  That way, if SLF4J is logging
> > to Log4J, or if SLF4J is logging to JCL which is logging to Log4J, we
> > would log
> > to Log4J as well.    If SLF4J is logging to someplace else, we'd still
> > log to
> > j.u.l so that wouldn't change.
> >
> > One note: with PAX logging in servicemix/felix, the ILoggerFactory would
> > not
> > contain "Log4j".  Thus, we'd continue to use j.u.l.  But that is OK as
> > PAX logging already interceptor j.u.l and directs them to the same place.
> >
> > Thoughts?  Comments?
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: CXF logging....

Posted by Benson Margulies <bi...@gmail.com>.
Why not just switch to sfl4j, defaulting to the j.u.l module?

On Tue, Oct 27, 2009 at 11:54 AM, Daniel Kulp <dk...@apache.org> wrote:

>
> As everyone is probably aware, CXF uses the j.u.l API for all of it's
> logging.
> That's really not likely to change, but we do allow logging to Log4J by
> setting some system properties or a file in META-INF/cxf.
>
> However,   I was thinking it might make sense to try and detect where SLF4J
> is
> logging and if it's logging to Log4J, we should as well.    The reflection
> code to do that isn't very complex:
>
> Class.forName("org/slf4j/impl/StaticLoggerBinder");
> Class<?> cls = Class.forName("org.slf4j.LoggerFactory");
> Class<?> fcls = cls.getMethod("getILoggerFactory").invoke(null).getClass();
> if (fcls.getName().contains("Log4j")) {
>    cname = "org.apache.cxf.common.logging.Log4jLogger";
> } else if (fcls.getName().contains("JCL")) {
>    cls = Class.forName("org.apache.commons.logging.LogFactory");
>    fcls = cls.getMethod("getFactory").invoke(null).getClass();
>    if (fcls.getName().contains("Log4j")) {
>        cname = "org.apache.cxf.common.logging.Log4jLogger";
>    }
> }
>
> What are peoples thoughts on doing that?  That way, if SLF4J is logging to
> Log4J, or if SLF4J is logging to JCL which is logging to Log4J, we would
> log
> to Log4J as well.    If SLF4J is logging to someplace else, we'd still log
> to
> j.u.l so that wouldn't change.
>
> One note: with PAX logging in servicemix/felix, the ILoggerFactory would
> not
> contain "Log4j".  Thus, we'd continue to use j.u.l.  But that is OK as PAX
> logging already interceptor j.u.l and directs them to the same place.
>
> Thoughts?  Comments?
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>