Aruna Karunarathna
Aruna Karunarathna

Reputation: 1021

Is there a way to get all log events in osgi pax logging

Is there a way to get all log events in pax logging?. I tried to getthe log events using following code. But no luck. Any idea on how to get all log events?

logReaderService.addLogListener(new TestLogListener()); //org.osgi.service.log.LogReaderService 

//sample log listener
class TestLogListener implements org.osgi.service.log.LogListener {
    private static final Logger logger = LoggerFactory.getLogger(TestLogListener.class);
    @Override
    public void logged(LogEntry logEntry) {
        logger.info("LOG MESSAGE ::"+logEntry.getMessage());
    }
}

Upvotes: 1

Views: 176

Answers (1)

Christian Schneider
Christian Schneider

Reputation: 19606

Take a look at the karaf logging service:

https://github.com/apache/karaf/tree/master/log/src/main/java/org/apache/karaf/log/core

It creates a PaxAppender and registers it as a service. This will hook into pax logging to receive all log events.

Upvotes: 1

Related Questions