plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
/** * The logger name for a component with a non-null hint is <code>role.hint</code>. * <b>Warning</b>: this does not conform to logger name as class name convention. * (and what about <code>null</code> and <code>default</code> hint equivalence?) */ public Logger getLoggerForComponent( String role, String hint ) { return ( null == hint ? getLoggerForComponent( role ) : new Slf4jLogger( loggerFactory.getLogger( role + '.' + hint ) ) ); }
plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
/** * The logger name for a component with a non-null hint is <code>role.hint</code>. * <b>Warning</b>: this does not conform to logger name as class name convention. * (and what about <code>null</code> and <code>default</code> hint equivalence?) */ public Logger getLoggerForComponent( String role, String hint ) { return ( null == hint ? getLoggerForComponent( role ) : new Slf4jLogger( loggerFactory.getLogger( role + '.' + hint ) ) ); }
plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
/** * The logger name for a component with a non-null hint is <code>role.hint</code>. * <b>Warning</b>: this does not conform to logger name as class name convention. * (and what about <code>null</code> and <code>default</code> hint equivalence?) */ public Logger getLoggerForComponent( String role, String hint ) { return ( null == hint ? getLoggerForComponent( role ) : new Slf4jLogger( loggerFactory.getLogger( role + '.' + hint ) ) ); }
plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() );
/** * code from org.apache.maven.cli.MavenCli.container(CliRequest) * <p> * cf also https://github.com/igor-suhorukov/mvn-classloader/blob/master/dropship/src/main/java/com/github/smreed/dropship/ClassLoaderBuilder.java */ private static PlexusContainer mvnContainer() { ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jLoggerManager plexusLoggerManager = new Slf4jLoggerManager(); ClassWorld classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader()); DefaultPlexusContainer container = null; ContainerConfiguration cc = new DefaultContainerConfiguration() .setClassWorld(classWorld) .setClassPathScanning(PlexusConstants.SCANNING_INDEX) .setAutoWiring(true) .setName("maven"); try { container = new DefaultPlexusContainer(cc, new AbstractModule() { protected void configure() { bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory); } }); } catch (PlexusContainerException e) { LOGGER.error("unable to create PlexusContainer", e); } // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups container.setLookupRealm(null); container.setLoggerManager(plexusLoggerManager); Thread.currentThread().setContextClassLoader(container.getContainerRealm()); return container; }
protected void logging(AFCliRequest cliRequest) { cliRequest.setDebug(cliRequest.getCommandLine().hasOption(CLIManager.DEBUG)); cliRequest.setQuiet(!cliRequest.isDebug() && cliRequest.getCommandLine().hasOption(CLIManager.QUIET)); cliRequest.setShowErrors(cliRequest.isDebug() || cliRequest.getCommandLine().hasOption(CLIManager.ERRORS)); slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory); if (cliRequest.isDebug()) { cliRequest.getRequest().setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_DEBUG); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.DEBUG); } else if (cliRequest.isQuiet()) { cliRequest.getRequest().setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_ERROR); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR); } if (cliRequest.getCommandLine().hasOption(CLIManager.LOG_FILE)) { File logFile = new File(cliRequest.getCommandLine().getOptionValue(CLIManager.LOG_FILE).trim()); logFile = resolveFile(logFile, cliRequest.getWorkingDirectory()); try { PrintStream ps = new PrintStream(new FileOutputStream(logFile)); System.setOut(ps); System.setErr(ps); } catch (FileNotFoundException e) { logger.error(e.getMessage()); } } slf4jConfiguration.activate(); plexusLoggerManager = new Slf4jLoggerManager(); slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName()); }
protected void logging(AFCliRequest cliRequest) { cliRequest.setDebug(cliRequest.getCommandLine().hasOption(CLIManager.DEBUG)); cliRequest.setQuiet(!cliRequest.isDebug() && cliRequest.getCommandLine().hasOption(CLIManager.QUIET)); cliRequest.setShowErrors(cliRequest.isDebug() || cliRequest.getCommandLine().hasOption(CLIManager.ERRORS)); slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory); if (cliRequest.isDebug()) { cliRequest.getRequest().setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_DEBUG); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.DEBUG); } else if (cliRequest.isQuiet()) { cliRequest.getRequest().setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_ERROR); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR); } if (cliRequest.getCommandLine().hasOption(CLIManager.LOG_FILE)) { File logFile = new File(cliRequest.getCommandLine().getOptionValue(CLIManager.LOG_FILE).trim()); logFile = resolveFile(logFile, cliRequest.getWorkingDirectory()); try { PrintStream ps = new PrintStream(new FileOutputStream(logFile)); System.setOut(ps); System.setErr(ps); } catch (FileNotFoundException e) { logger.error(e.getMessage()); } } slf4jConfiguration.activate(); plexusLoggerManager = new Slf4jLoggerManager(); reusableSlf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName()); }
Slf4jLoggerManager mavenLoggerManager = new Slf4jLoggerManager(); container.setLoggerManager( mavenLoggerManager );
mavenRequest.setMavenLoggerManager( new Slf4jLoggerManager() );