After reading about this, I felt like I understood it and now I am left baffled. Here is what I expect and what I did:
I expect to log into Karaf, reload my bundle, and run log:tail
and eventually see a log message like this:
13:28:47.265 INFO [Blueprint] You just created a class called: MyClass.
Technologies used: - OSGI Container implemented by Apache Karaf - Blueprint implemented by Aries
My OSGI bundle imports the pax logger from Karaf
org.slf4j.*; provider=paxlogging
to my understanding, this means that a reference to to the singleton logger of Karaf will be provided at runtime to my application, which only uses an API.
My classes use the SLF4J interface, so the dependency
slf4j-api:slf4j-api:1.7.26
exists in my project.A class exists
Class serves a model
public class MyClass {
private static final Logger LOGGER = LoggerFactory.getLogger(MyClass.class);
public MyClass() {
LOGGER.info("You just created a class called: {}", this);
}
@Override
public String toString() { return "MyClass" };
}
I just followed the specifications for an OSGI LoggerFactory:
Consumers of this API must not implement this type https://osgi.org/specification/osgi.cmpn/7.0.0/service.log.html#org.osgi.service.log.LoggerFactory
- Aries creates one:
Blueprint XML
<?xml version="1.0" encoding="UTF-8" ?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<description>
A sample Blueprint XML to demonstrate
the initialization procedure in the hopes of reproducing a problem.
</description>
<bean id="myclass1" class=com.stack.MyClass/>
</blueprint>