Using logback with Karaf 3.0.5 running under ServiceMix

馋奶兔 提交于 2020-01-05 18:01:08

问题


I am trying to use logback with Karaf 3.0.5 running under ServiceMix. This is what I have done till now as mentioned in this question.

This is what I have done till now:-

  1. Removed pax-logging-service by doing uninstall <pax-logging-bundle-id>
  2. Removed lib/bin/karaf-client.jar
  3. Inside lib placed the following jars:- jcl-over-slf4j-1.7.13, jul-to-slfj-17.13.jar, logback-classic-1.0.13.jar, logback-core-1.0.13.jar & osgi-over-slf4j-1.7.13.jar
  4. From /etc/startup.properties - removed references to pax-logging-service and pax-logging-api
  5. In etc/config.properties under org.osgi.framework.system.packages.extraadded the following packages:- ch.qos.logback; version="1.0.13", \ org.slf4j; version="1.7.13", \
  6. Created a logback.xml and and placed it inside /etc.
  7. Commented out everything in etc/org.ops4j.pax.logging.cfg
  8. In etc/system.properties add logback.configurationFile="etc/logback.xml"

My logback.xml looks like below:-

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    </appender>
    <appender name="FILE"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>/var/log/workflow/WorkFlow.%d{yyyy-MM-dd}.log
            </fileNamePattern>
            <maxHistory>7</maxHistory>
        </rollingPolicy>
    </appender>
    <root level="info">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </root>
</configuration>

Karaf info reports the following:-

karaf@root>info
Karaf
  Karaf version               3.0.5
  Karaf home                  /home/jabong/Downloads/software/dev/apache-servicemix-6.1.0
  Karaf base                  /home/jabong/Downloads/software/dev/apache-servicemix-6.1.0
  Karaf etc                   /home/jabong/Downloads/software/dev/apache-servicemix-6.1.0/etc
  OSGi Framework              org.apache.felix.framework - 4.2.1

But after making the above changes we are not seeing any log file under /var/log/workflow nor I am seeing the info logs.


回答1:


To resolve this issue, you could place your pax-logging-logback jar under the system directory of the karaf/servicemix and then you could replace your org.ops4j.pax.logging with below configuration.

# use logback config
org.ops4j.pax.logging.logback.config.file=${karaf.base}/config/logback.xml
# set default 'osgi' logging level
org.ops4j.pax.logging.DefaultServiceLog.level=WARN

And place your logback.xml under config folder.



来源:https://stackoverflow.com/questions/35628958/using-logback-with-karaf-3-0-5-running-under-servicemix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!