我正在尝试使用在ServiceMix下运行的Karaf 3.0.5的logback。这是我迄今为止所做的事情,如question所述。
这是我迄今为止所做的: -
pax-logging-service
uninstall <pax-logging-bundle-id>
lib/bin/karaf-client.jar
lib
内放置了以下广告: - jcl-over-slf4j-1.7.13
,jul-to-slfj-17.13.jar
,logback-classic-1.0.13.jar
,logback-core-1.0.13.jar
&amp;
osgi-over-slf4j-1.7.13.jar
/etc/startup.properties
- 删除了对pax-logging-service
和pax-logging-api
etc/config.properties
org.osgi.framework.system.packages.extra
下添加了以下软件包: -
ch.qos.logback; version="1.0.13", \
org.slf4j; version="1.7.13", \
logback.xml
并将其放在/etc
内。etc/org.ops4j.pax.logging.cfg
etc/system.properties
添加logback.configurationFile="etc/logback.xml"
我的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
下的任何日志文件,也没有看到信息日志。
答案 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放在配置文件夹下。