我配置了Karaf 4.0.5以修复此issue,但我的捆绑包的日志输出仅显示在karaf控制台中,而不是文件中。它适用于Karaf 4.0.3。
任何想法为什么我的捆绑包的输出只出现在Karaf控制台?
我为配置log4j2所做的更改:
startup.properties(相应的jar位于$ {karaf.system}文件夹中):
mvn:org.ops4j.pax.logging / pax-logging-api / 1.8.5 = 8
(此行已注释)mvn:org.ops4j.pax.logging / pax-logging-service / 1.8.5 = 8
mvn:org.ops4j.pax.logging / pax-logging-log4j2 / 1.8.5 = 8
mvn:com.lmax / disruptor / 3.3.2 = 8
org.ops4j.pax.logging.cfg:
org.ops4j.pax.logging.log4j2.config.file = $ {karaf.etc} /log4j2.xml org.ops4j.pax.logging.log4j2.async = true
system.properties
log4j.configurationFile =文件:$ {karaf.etc} /log4j2.xml
org.ops4j.pax.logging.DefaultServiceLog.level = DEBUG
Log4jContextSelector = org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="ALL">
<Appenders>
<RollingRandomAccessFile name="oapiserver" fileName="data/log/log4j2.log" filePattern="data/log/oapi-%d_%i.log.gz" immediateFlush="false">
<ThresholdFilter level="DEBUG"/>
<PatternLayout>
<pattern>%level{length=1} %date{MMdd-HHmm:ss,SSS} %logger{1.} %message [%thread]%n</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="50 MB"/>
</Policies>
<DefaultRolloverStrategy max="10000"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="oapiserver"/>
</Root>
</Loggers>
答案 0 :(得分:0)
对于karaf-4.0.4: 请参阅4.0.5发行说明-[ KARAF-4278 ]-清理无效。 因此,在配置log4j2之后,要么从karaf服务器中删除数据目录。
对于karaf-4.0.5: 配置后运行karaf clean