使用在ServiceMix下运行的Karaf 3.0.5的logback

时间:2016-02-25 13:40:54

标签: logback apache-karaf apache-servicemix

我正在尝试使用在ServiceMix下运行的Karaf 3.0.5的logback。这是我迄今为止所做的事情,如question所述。

这是我迄今为止所做的: -

  1. 通过执行pax-logging-service
  2. 删除了uninstall <pax-logging-bundle-id>
  3. 已移除lib/bin/karaf-client.jar
  4. lib内放置了以下广告: - jcl-over-slf4j-1.7.13jul-to-slfj-17.13.jarlogback-classic-1.0.13.jarlogback-core-1.0.13.jar&amp; osgi-over-slf4j-1.7.13.jar
  5. 来自/etc/startup.properties - 删除了对pax-logging-servicepax-logging-api
  6. 的引用
  7. etc/config.properties org.osgi.framework.system.packages.extra下添加了以下软件包: - ch.qos.logback; version="1.0.13", \ org.slf4j; version="1.7.13", \
  8. 创建logback.xml并将其放在/etc内。
  9. etc/org.ops4j.pax.logging.cfg
  10. 中注明了所有内容
  11. etc/system.properties添加logback.configurationFile="etc/logback.xml"
  12. 我的logback.xml如下所示: -

    <?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报告如下: -

    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
    

    但是在进行上述更改后,我们看不到/var/log/workflow下的任何日志文件,也没有看到信息日志。

1 个答案:

答案 0 :(得分:0)

要解决此问题,可以将pax-logging-logback jar放在karaf / servicemix的系统目录下,然后可以用以下配置替换org.ops4j.pax.logging。

# 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

并将您的logback.xml放在配置文件夹下。