I'm trying to limit the log level to INFO in webconsole and to DEBUG in Log file. I have tried this: in org.ops4j.pax.logging.cfg:
# Root logger
log4j.rootLogger=INFO, out, osgi:*
log4j.throwableRenderer=org.apache.log4j.OsgiThrowableRenderer
# File appender
log4j.appender.out.threshold=DEBUG
log4j.appender.out=org.apache.log4j.RollingFileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n
log4j.appender.out.file=${karaf.data}/log/karaf.log
log4j.appender.out.append=true
log4j.appender.out.maxFileSize=1MB
log4j.appender.out.maxBackupIndex=10
this is the route: blueprint.xml:
<route id="timerToLog">
<from uri="timer:foo?period=5000"/>
<setBody>
<method ref="helloBean" method="hello"/>
</setBody>
<log message="The message contains ${body}" loggingLevel="DEBUG"/>
<log message="ok" loggingLevel="INFO"/>
</route>
But i got only INFO log in Log file and not DEBUG. How can i do it ?
In log4j the levels are first calculated on the logger level. Only the messages that pass this filtering will go into the appenders.
So you would need to use DEBUG level on the root level and then use INFO for some appenders.
Not sure if you can selectively limit what goes to the webconsole though.