I have a library that uses Plexus Logging facilities. My project configures it's own logging through slf4j with slf4j-simple.
I've tried to mute the logging in the library through simplelogger.properties
using
org.slf4j.simpleLogger.log.com.acme.lib=off
This had no effect.
Debugging into the culprit class, I found that it's injected a org.codehaus.plexus.logging.Logger
. Whenever I get my component from the container, that Logger
is an org.codehaus.plexus.logging.console.ConsoleLogger
.
I tried to bind my own NoOp implementation of the logger for injection like so:
PlexusContainer container = new DefaultPlexusContainer();
// other components
// remove all Logger components
container.releaseAll(container.lookupList(Logger.class));
container.addComponent(new NoOpLogger(), Logger.class, "default");
But that did not have an effect on the actually injected logger instance.
I was able to obtain my Logger implementation from the container using container.lookup(Logger.class)
, but the component still used it's ConsoleLogger
.
To remedy that I tried to register a LoggerManager
that'd construct my logger implementations like so:
// code from above, and additionally
container.releaseAll(container.lookupList(LoggerManager.class));
container.addComponent(new NoOpLoggerManager(), LoggerManager.class, "default");
While I now can also obtain my LoggerManager
from the container, still the ConsoleLogger
is injected to the Library's component.
How can I make sure my NoOpLogger
is injected into the component?