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 <[email protected]>:

> 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

Reply via email to