Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
private void disableLogging() throws MojoExecutionException { // Maven < 3.1 Logger logger; try { logger = (Logger) FieldUtils.readField(getLog(), "logger", true); } catch (IllegalAccessException e) { throw new MojoExecutionException("Unable to access logger field ", e); } logger.setThreshold(5); // Maven >= 3.1 ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR); slf4jConfiguration.activate(); } }
private void disableLogging() throws MojoExecutionException { // Maven < 3.1 Logger logger; try { logger = (Logger) FieldUtils.readField(getLog(), "logger", true); } catch (IllegalAccessException e) { throw new MojoExecutionException("Unable to access logger field ", e); } logger.setThreshold(5); // Maven >= 3.1 ILoggerFactory slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory); slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR); slf4jConfiguration.activate(); } }
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory );
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()); }
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()); }