You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by asookazian2 <as...@gmail.com> on 2014/08/13 17:33:42 UTC

No appenders could be found for logger (log4j related)

We are seeing the following message when deploying a WAR bundle and starting
karaf 3.0.1:

admin@NextGate ()> log4j:WARN No appenders could be found for logger
(org.springframework.web.servlet.DispatcherServlet).
log4j:WARN Please initialize the log4j system properly.

I was told to remove log4j and use 'mvn dependency:tree' to determine how
the transitive dependency is happening:

i executed the following cmd: mvn dependency:tree -Dverbose -Dincludes=log4j
10:28 [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @
RelationManager-OSGi ---
[INFO]
com.nextgate.mm.relation.deploys:RelationManager-OSGi:war:1.0.0-SNAPSHOT
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:compile
[INFO] |  \- (log4j:log4j:jar:1.2.16:compile - version managed from 1.2.17;
omitted for duplicate)
[INFO] \- log4j:log4j:jar:1.2.16:compile

I tried to remove the log4j reference in the bundle-classpath for
maven-bundle-plugin config but starting seeing other exceptions
(ClassNotFoundExceptions for log4j classes).

This is what is relevant in the bundle-classpath for the maven-bundle-plugin
section in pom.xml for this WAR project.  I have tried removing
log4j-1.2.16.jar and slf4j-api-1.7.2.jar and see various exceptions in
karaf.log.

<Bundle-ClassPath>.
...
,WEB-INF/lib/log4j-1.2.16.jar
,WEB-INF/lib/slf4j-api-1.7.2.jar
,WEB-INF/lib/slf4j-log4j12-1.7.2.jar
...
</Bundle-ClassPath>

Now I have finally resorted to including a log4j.xml file in the root of the
WAR so that log4j will find it in the classpath.  Now the WARN logging above
to the karaf console is gone but the logging for the file appender has a
different format than what is in the karaf.log.

Here is my current log4j.xml config.  I was thinking about using
"./data/log/karaf.log" and appending to that log instead of a test.log.

   
   <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
     
     
     
     
     

     <layout class="org.apache.log4j.PatternLayout">
       
     </layout>	    
   </appender>

Am I missing something simple here (i.e. making this too complicated as a
solution)?  Any assistance is appreciated. thx.



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
Rugby, man that's tough!  hope you're ok. ;)

http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-core/2.5.4/org/springframework/util/Log4jConfigurer.java

This class is using LogManager...


jbonofre wrote
> Hi guys,
> 
> sorry I was out for a rugby game ;)
> 
> Pax Logging wraps log4j, it doesn't import the whole log4j api.
> Some part of the log4j API is not included because all doesn't make 
> sense in OSGi.
> It's the case for org.apache.log4j.LogManager: it's part of log4j but 
> it's not included in pax-logging (api or service).
> 
> In the latest pax-logging release, I included a couple of Log4j and 
> SLf4j new classes, but not this one as it's not really usefull in OSGi 
> (due to the Logging service).
> 
> So, what's your usage of LogManager ? I'm pretty sure you can avoid to 
> use it.
> 
> Regards
> JB
> 
> On 08/13/2014 10:21 PM, asookazian2 wrote:
>> Thanks for the tip. I tried this and it did not work.
>>
>> Still seeing exception in the karaf.log:
>>
>> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager
>> not
>> found by org.ops4j.pax.logging.pax-logging-api [7]
>>
>> I will try to research the response that Achim gave.  thx guys.
>>
>>
>> bane73 wrote
>>> Not really the most correct answer, but try modifying your export
>>> section
>>> to export everything.
>>> That SHOULD work, I believe, because your project is using that JAR
>>> (thus,
>>> it's contained inside of it) but you are not telling OSGI that you want
>>> to
>>> use it and so it is blocking it from your JAR's classpath.
>>>
>>> IOW, in your POM right below the
>>> 
> <Bundle-ClassPath>
>>>   section you should have a
>>> 
> <Export-Package>
>>>   section.  Delete everything and replace with a wildcard:
>>>
>>> ie:
>>> 
> <Export-Package>
>>> *
>>> 
> </Export-Package>
>>> That should do the trick.  If it does, don't settle for that though. 
>>> The
>>> correct answer is, I think, to install org.apache.log4j either as it's
>>> own
>>> bundle or as a part of a "dependency"-bundle.  I'm still pretty new to
>>> OSGI, though, so I could be wrong.
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034752.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>>
> 
> -- 
> Jean-Baptiste Onofré

> jbonofre@

> http://blog.nanthrax.net
> Talend - http://www.talend.com





--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034756.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi guys,

sorry I was out for a rugby game ;)

Pax Logging wraps log4j, it doesn't import the whole log4j api.
Some part of the log4j API is not included because all doesn't make 
sense in OSGi.
It's the case for org.apache.log4j.LogManager: it's part of log4j but 
it's not included in pax-logging (api or service).

In the latest pax-logging release, I included a couple of Log4j and 
SLf4j new classes, but not this one as it's not really usefull in OSGi 
(due to the Logging service).

So, what's your usage of LogManager ? I'm pretty sure you can avoid to 
use it.

Regards
JB

On 08/13/2014 10:21 PM, asookazian2 wrote:
> Thanks for the tip. I tried this and it did not work.
>
> Still seeing exception in the karaf.log:
>
> Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager not
> found by org.ops4j.pax.logging.pax-logging-api [7]
>
> I will try to research the response that Achim gave.  thx guys.
>
>
> bane73 wrote
>> Not really the most correct answer, but try modifying your export section
>> to export everything.
>> That SHOULD work, I believe, because your project is using that JAR (thus,
>> it's contained inside of it) but you are not telling OSGI that you want to
>> use it and so it is blocking it from your JAR's classpath.
>>
>> IOW, in your POM right below the
>> <Bundle-ClassPath>
>>   section you should have a
>> <Export-Package>
>>   section.  Delete everything and replace with a wildcard:
>>
>> ie:
>> <Export-Package>
>> *
>> </Export-Package>
>> That should do the trick.  If it does, don't settle for that though.  The
>> correct answer is, I think, to install org.apache.log4j either as it's own
>> bundle or as a part of a "dependency"-bundle.  I'm still pretty new to
>> OSGI, though, so I could be wrong.
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034752.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
Thanks for the tip. I tried this and it did not work.

Still seeing exception in the karaf.log:

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager not
found by org.ops4j.pax.logging.pax-logging-api [7]

I will try to research the response that Achim gave.  thx guys.


bane73 wrote
> Not really the most correct answer, but try modifying your export section
> to export everything.
> That SHOULD work, I believe, because your project is using that JAR (thus,
> it's contained inside of it) but you are not telling OSGI that you want to
> use it and so it is blocking it from your JAR's classpath.  
> 
> IOW, in your POM right below the 
> <Bundle-ClassPath>
>  section you should have a 
> <Export-Package>
>  section.  Delete everything and replace with a wildcard:
> 
> ie: 
> <Export-Package>
> *
> </Export-Package>
> That should do the trick.  If it does, don't settle for that though.  The
> correct answer is, I think, to install org.apache.log4j either as it's own
> bundle or as a part of a "dependency"-bundle.  I'm still pretty new to
> OSGI, though, so I could be wrong.





--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034752.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
I commented out the below listener block in the web.xml.  Now it seems to be
behaving better (no exceptions) but I'm not sure what side-effect it may
have to remove that...


asookazian2 wrote
> In the web.xml:
> <listener>
>         
> <listener-class>
> org.springframework.web.util.Log4jConfigListener
> </listener-class>
>     
> </listener>
> Should we be using a different listener?





--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034757.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
In the web.xml:

<listener>
       
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

Should we be using a different listener?



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034755.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
Upon closer inspection it appears that a Spring class is involved in the
problem:

20140813 13:10:13.628 [WARN ] FelixStartLevel |
69:org.eclipse.jetty.aggregate.jetty-all-server |
org.eclipse.jetty.util.component.AbstractLifeCycle | FAILED
HttpServiceContext{httpContext=WebAppHttpContext{RelationManager-OSGi -
243}}: java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
	at
org.springframework.util.Log4jConfigurer.shutdownLogging(Log4jConfigurer.java:117)
	at
org.springframework.web.util.Log4jWebConfigurer.shutdownLogging(Log4jWebConfigurer.java:170)
	at
org.springframework.web.util.Log4jConfigListener.contextDestroyed(Log4jConfigListener.java:51)

I will inspect the applicationContext.xml to see if it is configured to use
log4j....



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034754.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by Achim Nierbeck <bc...@googlemail.com>.
First of all, if you want to have a working logging with Karaf, use the
logging provided by it.
Karaf uses Pax Logging which supports a wide range of logging frameworks.
So don't embed log4j in your bundles. It's not needed and just doesn't work
that way!

You also should check the way you do your logging. Either you have a custom
appender which needs to be registered in a different way.
Or you doing something else strange.
Cause usually a logging like the following is sufficient:

LoggerFactory.getLogger(LoggingClass.class);
log.error("this is my error message with content {}", content); //slf4j
style logging

For using a custom appender (or something similar), you either might check
the mailing-list or take a look at [1].

regards, Achim

[1] -
http://notizblog.nierbeck.de/2011/08/adding-custom-log-appender-to-pax-logging/




2014-08-13 20:35 GMT+02:00 bane73 <br...@thegreshams.net>:

> Not really the most correct answer, but try modifying your export section
> to
> export everything.
> That SHOULD work, I believe, because your project is using that JAR (thus,
> it's contained inside of it) but you are not telling OSGI that you want to
> use it and so it is blocking it from your JAR's classpath.
>
> IOW, in your POM right below the <Bundle-ClassPath> section you should have
> a <Export-Package> section.  Delete everything and replace with a wildcard:
>
> ie: <Export-Package>*</Export-Package>
>
> That should do the trick.  If it does, don't settle for that though.  The
> correct answer is, I think, to install org.apache.log4j either as it's own
> bundle or as a part of a "dependency"-bundle.  I'm still pretty new to
> OSGI,
> though, so I could be wrong.
>
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034748.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

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

Software Architect / Project Manager / Scrum Master

Re: No appenders could be found for logger (log4j related)

Posted by bane73 <br...@thegreshams.net>.
Not really the most correct answer, but try modifying your export section to
export everything.
That SHOULD work, I believe, because your project is using that JAR (thus,
it's contained inside of it) but you are not telling OSGI that you want to
use it and so it is blocking it from your JAR's classpath.  

IOW, in your POM right below the <Bundle-ClassPath> section you should have
a <Export-Package> section.  Delete everything and replace with a wildcard:

ie: <Export-Package>*</Export-Package>

That should do the trick.  If it does, don't settle for that though.  The
correct answer is, I think, to install org.apache.log4j either as it's own
bundle or as a part of a "dependency"-bundle.  I'm still pretty new to OSGI,
though, so I could be wrong.





--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034748.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
So I added back the following to the <Bundle-ClassPath> section:

,WEB-INF/lib/log4j-1.2.16.jar

and still getting this exception on karaf startup.  I still have the import
for org.apache.log4j in the <Import-Package> section so not sure what else
to try at this point....

Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager not
found by org.ops4j.pax.logging.pax-logging-api [7]
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
	at
org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1374)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1553)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1484)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
	... 36 more



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034747.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
Ok so I removed the three JARs (one log4j and two slf4j) from the
<Bundle-ClassPath> section and added the following to the <package-import>
section:

<Import-Package>
...
,org.apache.log4j
,org.slf4j
...
</Import-Package>

Now I am not seeing the WARN in the console during karaf startup, but I am
seeing the following exception in the log.  Please advise how to resolve. 
Do I need to add log4j back to the bundle-classpath?  thx.

20140813 10:01:03.662 [WARN ] FelixStartLevel |
138:org.ops4j.pax.web.pax-web-extender-war |
org.ops4j.pax.web.extender.war.internal.Activator | Error while destroying
extension for bundle RelationManager-OSGi [242]
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError:
org/apache/log4j/LogManager
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)[:1.7.0_51]
	at java.util.concurrent.FutureTask.get(FutureTask.java:188)[:1.7.0_51]
	at
org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender.destroyExtension(AbstractExtender.java:309)[138:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
	at
org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender.bundleChanged(AbstractExtender.java:188)[138:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
	at
org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:868)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:789)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:514)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4403)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.Felix.stopBundle(Felix.java:2520)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1309)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)[org.apache.felix.framework-4.2.1.jar:]
	at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/LogManager
	at
org.springframework.util.Log4jConfigurer.shutdownLogging(Log4jConfigurer.java:117)
	at
org.springframework.web.util.Log4jWebConfigurer.shutdownLogging(Log4jWebConfigurer.java:170)
	at
org.springframework.web.util.Log4jConfigListener.contextDestroyed(Log4jConfigListener.java:51)
	at
org.eclipse.jetty.server.handler.ContextHandler.doStop(ContextHandler.java:823)
	at
org.eclipse.jetty.servlet.ServletContextHandler.doStop(ServletContextHandler.java:160)
	at
org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStop(HttpServiceContext.java:229)
	at
org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
	at
org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.stop(JettyServerImpl.java:202)
	at
org.ops4j.pax.web.service.internal.HttpServiceStarted.begin(HttpServiceStarted.java:1018)
	at
org.ops4j.pax.web.service.internal.HttpServiceProxy.begin(HttpServiceProxy.java:417)
	at
org.ops4j.pax.web.extender.war.internal.UnregisterWebAppVisitorWC.visit(UnregisterWebAppVisitorWC.java:82)
	at
org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:641)
	at
org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.unregister(WebAppPublisher.java:264)
	at
org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.removedService(WebAppPublisher.java:224)
	at
org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.removedService(WebAppPublisher.java:135)
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:956)[karaf-org.osgi.core.jar:]
	at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:864)[karaf-org.osgi.core.jar:]
	at
org.osgi.util.tracker.AbstractTracked.untrack(AbstractTracked.java:341)[karaf-org.osgi.core.jar:]
	at
org.osgi.util.tracker.ServiceTracker.close(ServiceTracker.java:375)[karaf-org.osgi.core.jar:]
	at
org.ops4j.pax.web.extender.war.internal.WebAppPublisher.unpublish(WebAppPublisher.java:127)
	at
org.ops4j.pax.web.extender.war.internal.WebObserver.undeploy(WebObserver.java:247)
	at
org.ops4j.pax.web.extender.war.internal.WebObserver$1.doDestroy(WebObserver.java:185)
	at
org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.destroy(SimpleExtension.java:70)
	at
org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$2.run(AbstractExtender.java:288)
	at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_51]
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_51]
	at
org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender.destroyExtension(AbstractExtender.java:308)[138:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
	... 9 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.LogManager not
found by org.ops4j.pax.logging.pax-logging-api [7]
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
	at
org.apache.felix.framework.BundleWiringImpl.getClassByDelegation(BundleWiringImpl.java:1374)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.searchImports(BundleWiringImpl.java:1553)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1484)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
	at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_51]
	... 36 more




--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034746.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
Achim, thx for reply!  So I need to use <Import-Package> only instead of
<Bundle-Classpath>?

And if yes, which packages do I need to import specifically?



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034743.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: No appenders could be found for logger (log4j related)

Posted by Achim Nierbeck <bc...@googlemail.com>.
If you want to use logging, you shouldn't contain those jars in your war
file.
Use Package-Import instead.
The Maven-Bundle-Plugin is your friend in helping to resolve those
dependencies.

regards, Achim


2014-08-13 17:33 GMT+02:00 asookazian2 <as...@gmail.com>:

> We are seeing the following message when deploying a WAR bundle and
> starting
> karaf 3.0.1:
>
> admin@NextGate ()> log4j:WARN No appenders could be found for logger
> (org.springframework.web.servlet.DispatcherServlet).
> log4j:WARN Please initialize the log4j system properly.
>
> I was told to remove log4j and use 'mvn dependency:tree' to determine how
> the transitive dependency is happening:
>
> i executed the following cmd: mvn dependency:tree -Dverbose
> -Dincludes=log4j
> 10:28 [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @
> RelationManager-OSGi ---
> [INFO]
> com.nextgate.mm.relation.deploys:RelationManager-OSGi:war:1.0.0-SNAPSHOT
> [INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.2:compile
> [INFO] |  \- (log4j:log4j:jar:1.2.16:compile - version managed from 1.2.17;
> omitted for duplicate)
> [INFO] \- log4j:log4j:jar:1.2.16:compile
>
> I tried to remove the log4j reference in the bundle-classpath for
> maven-bundle-plugin config but starting seeing other exceptions
> (ClassNotFoundExceptions for log4j classes).
>
> This is what is relevant in the bundle-classpath for the
> maven-bundle-plugin
> section in pom.xml for this WAR project.  I have tried removing
> log4j-1.2.16.jar and slf4j-api-1.7.2.jar and see various exceptions in
> karaf.log.
>
> <Bundle-ClassPath>.
> ...
> ,WEB-INF/lib/log4j-1.2.16.jar
> ,WEB-INF/lib/slf4j-api-1.7.2.jar
> ,WEB-INF/lib/slf4j-log4j12-1.7.2.jar
> ...
> </Bundle-ClassPath>
>
> Now I have finally resorted to including a log4j.xml file in the root of
> the
> WAR so that log4j will find it in the classpath.  Now the WARN logging
> above
> to the karaf console is gone but the logging for the file appender has a
> different format than what is in the karaf.log.
>
> Here is my current log4j.xml config.  I was thinking about using
> "./data/log/karaf.log" and appending to that log instead of a test.log.
>
>
>    <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
>
>
>
>
>
>
>      <layout class="org.apache.log4j.PatternLayout">
>
>      </layout>
>    </appender>
>
> Am I missing something simple here (i.e. making this too complicated as a
> solution)?  Any assistance is appreciated. thx.
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

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

Software Architect / Project Manager / Scrum Master

Re: No appenders could be found for logger (log4j related)

Posted by asookazian2 <as...@gmail.com>.
This works:

   <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
     
     
     
     

     <layout class="org.apache.log4j.PatternLayout">
       
     </layout>	    
   </appender>

This does *not* work (i.e. no logging of the same above contents in test.log
are visible in the karaf.log; why?)

   <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
     
     
     
     

     <layout class="org.apache.log4j.PatternLayout">
       
     </layout>	    
   </appender>



--
View this message in context: http://karaf.922171.n3.nabble.com/No-appenders-could-be-found-for-logger-log4j-related-tp4034739p4034742.html
Sent from the Karaf - User mailing list archive at Nabble.com.