You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by maaruks <ma...@gmail.com> on 2012/05/03 12:59:41 UTC

log4j

Is it possible to use log4j in karaf ?

I have log4j classes in my bundle but I cant access them:

        try {
            Class<?> aClass = Class.forName("org.apache.log4j.Appender");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }



java.lang.RuntimeException: java.lang.ClassNotFoundException:
org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api
[4]
.......
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender not
found by org.ops4j.pax.logging.pax-logging-api [4]
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
    at
org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
    at
org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
    at
org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)
    at
org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
    at
org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
    at java.lang.Class.forName0(Native Method)[:1.6.0_26]
    at java.lang.Class.forName(Class.java:169)[:1.6.0_26]


--
View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: log4j

Posted by Guillaume Nodet <gn...@gmail.com>.
Custom appenders can be deployed by using fragments attached to the
pax-logging-service bundle fwiw.

On Thu, May 3, 2012 at 1:21 PM, Achim Nierbeck <bc...@googlemail.com>wrote:

> I'm not sure what you are trying to do, but log4j as slf4j and a
> couple more logging framworks are supported by Karaf.
> We use Pax Logging for this, log4j is even the underlying
> implementation for logging.
> If you want to use your own appenders you need to take special care for
> this.
>
> Regards, Achim
>
> 2012/5/3 maaruks <ma...@gmail.com>:
> > Is it possible to use log4j in karaf ?
> >
> > I have log4j classes in my bundle but I cant access them:
> >
> >        try {
> >            Class<?> aClass = Class.forName("org.apache.log4j.Appender");
> >        } catch (ClassNotFoundException e) {
> >            throw new RuntimeException(e);
> >        }
> >
> >
> >
> > java.lang.RuntimeException: java.lang.ClassNotFoundException:
> > org.apache.log4j.Appender not found by
> org.ops4j.pax.logging.pax-logging-api
> > [4]
> > .......
> > Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender
> not
> > found by org.ops4j.pax.logging.pax-logging-api [4]
> >    at
> >
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
> >    at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
> >    at
> >
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
> >    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
> >    at
> >
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
> >    at
> > org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
> >    at
> > org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)
> >    at
> >
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)
> >    at
> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
> >    at
> >
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
> >    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
> >    at java.lang.Class.forName0(Native Method)[:1.6.0_26]
> >    at java.lang.Class.forName(Class.java:169)[:1.6.0_26]
> >
> >
> > --
> > View this message in context:
> http://karaf.922171.n3.nabble.com/log4j-tp3958839.html
> > Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
>
> --
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
> Committer & Project Lead
> OPS4J Pax Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
> Commiter & Project Lead
> blog <http://notizblog.nierbeck.de/>
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com

Re: log4j

Posted by Guillaume Nodet <gn...@gmail.com>.
That's really the best thing to do in karaf, as the log configuration is
handled in an osgi way, so no code should try to directly configure the
logging framework.

On Fri, May 4, 2012 at 1:01 PM, maaruks <ma...@gmail.com> wrote:

>
> Achim Nierbeck wrote
> >
> > I'm not sure what you are trying to do, but log4j as slf4j and a
> > couple more logging framworks are supported by Karaf.
> >
>
> I am migrating some code to karaf.    It turns out Pax Logging doesn't
> allow
> to access all log4j classes.
> I removed code that is trying to access Appender.  Problem solved.
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/log4j-tp3958839p3961902.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com

Re: log4j

Posted by maaruks <ma...@gmail.com>.
Achim Nierbeck wrote
> 
> I'm not sure what you are trying to do, but log4j as slf4j and a
> couple more logging framworks are supported by Karaf.
> 

I am migrating some code to karaf.    It turns out Pax Logging doesn't allow
to access all log4j classes.
I removed code that is trying to access Appender.  Problem solved.


--
View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839p3961902.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: log4j

Posted by Achim Nierbeck <bc...@googlemail.com>.
I'm not sure what you are trying to do, but log4j as slf4j and a
couple more logging framworks are supported by Karaf.
We use Pax Logging for this, log4j is even the underlying
implementation for logging.
If you want to use your own appenders you need to take special care for this.

Regards, Achim

2012/5/3 maaruks <ma...@gmail.com>:
> Is it possible to use log4j in karaf ?
>
> I have log4j classes in my bundle but I cant access them:
>
>        try {
>            Class<?> aClass = Class.forName("org.apache.log4j.Appender");
>        } catch (ClassNotFoundException e) {
>            throw new RuntimeException(e);
>        }
>
>
>
> java.lang.RuntimeException: java.lang.ClassNotFoundException:
> org.apache.log4j.Appender not found by org.ops4j.pax.logging.pax-logging-api
> [4]
> .......
> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Appender not
> found by org.ops4j.pax.logging.pax-logging-api [4]
>    at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
>    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>    at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
>    at
> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>    at
> org.apache.felix.framework.resolver.WireImpl.getClass(WireImpl.java:99)
>    at
> org.apache.felix.framework.ModuleImpl.searchImports(ModuleImpl.java:1390)
>    at
> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:722)
>    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>    at
> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)[:1.6.0_26]
>    at java.lang.Class.forName0(Native Method)[:1.6.0_26]
>    at java.lang.Class.forName(Class.java:169)[:1.6.0_26]
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/log4j-tp3958839.html
> Sent from the Karaf - User mailing list archive at Nabble.com.



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
OPS4J Pax Vaadin <http://team.ops4j.org/wiki/display/PAXVAADIN/Home>
Commiter & Project Lead
blog <http://notizblog.nierbeck.de/>