Example usage for org.apache.maven.cli.logging Slf4jConfiguration setRootLoggerLevel

List of usage examples for org.apache.maven.cli.logging Slf4jConfiguration setRootLoggerLevel

Introduction

In this page you can find the example usage for org.apache.maven.cli.logging Slf4jConfiguration setRootLoggerLevel.

Prototype

void setRootLoggerLevel(Level level);

Source Link

Document

Set root logging level.

Usage

From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java

License:Apache License

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);
    }/*  w w w . j a va  2s. co m*/

    if (cliRequest.getCommandLine().hasOption(CLIManager.LOG_FILE)) {
        File logFile = new File(cliRequest.getCommandLine().getOptionValue(CLIManager.LOG_FILE).trim());
        logFile = resolveFile(logFile, cliRequest.getWorkingDirectory()); //@MAX

        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());
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.AFMavenCli.java

License:Apache License

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);
    }//w w  w .  j  av  a2s.  co  m

    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());
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java

License:Apache License

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);
    }//from w  ww  .  ja v  a 2s .  c om

    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());
}