Maven uses Plexus Container logging API, like any other Plexus components, ie LoggerManager / Logger.
Starting with Maven 3.1.0, instead of implementing the API itself, Maven maps to SLF4J API's ILoggerFactory / Logger through Slf4jLoggerManager / Slf4jLogger.
Plexus Logger and LoggerManager can be injected in Plexus component using Plexus annotations
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; @Component( role = MyComponent.class ) public class DefaultMyComponent implements MyComponent { @Requirement private Logger logger; @Requirement private LoggerManager loggerManager; }
Starting with Maven 3.1.0, SLF4J Logger can be used directly too, without Plexus. Of course, this will only work when run under Maven 3.1.0, then this technique can be used safely only in Maven core components.
import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class MyClass { final Logger logger = LoggerFactory.getLogger( MyClass.class ); }
Before Maven 3.1.0, with logging implementation done in Maven, logger name wasn't used: they are as-is, without clear definition.
Starting with Maven 3.1.0, logging implementation can be of greatest use if logger names are well defined. This definition still needs to be defined and implemented: