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

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

Introduction

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

Prototype

void activate();

Source Link

Document

Activate logging implementation configuration (if necessary).

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);
    }//from w ww. j av  a2 s .  c o  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);
    }//from w  w  w . j  a va 2  s .  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 www  .  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());

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