Example usage for java.lang System setErr

List of usage examples for java.lang System setErr

Introduction

In this page you can find the example usage for java.lang System setErr.

Prototype

public static void setErr(PrintStream err) 

Source Link

Document

Reassigns the "standard" error output stream.

Usage

From source file:org.eclipse.virgo.medic.impl.LogController.java

private synchronized void updateLogConfiguration(Dictionary<String, Object> configuration) {
    String logSysOutConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSOUT);
    if (Boolean.valueOf(logSysOutConfiguration)) {
        delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut,
                LOGGER_NAME_SYSOUT_DELEGATE);
        sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT);

        System.setOut(wrapPrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor,
                configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT));
    } else {//from   ww  w .  ja  va2s .  com
        if (Boolean.FALSE.toString().equals(logSysOutConfiguration)) {
            if (delegatingSysOutRegistration != null) {
                registrationTracker.unregister(delegatingSysOutRegistration);
                delegatingSysOutRegistration = null;
            }
            if (sysOutRegistration != null) {
                registrationTracker.unregister(sysOutRegistration);
                sysOutRegistration = null;
            }
            System.setOut((PrintStream) delegatingSysOut);
        } else {
            delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut,
                    LOGGER_NAME_SYSOUT_DELEGATE);
            sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT);

            System.setOut(decoratePrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor,
                    configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT));

            if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysOutConfiguration)) {
                System.out.println("Invalid value '" + logSysOutConfiguration + "' for configuration key '"
                        + ConfigurationProvider.KEY_LOG_WRAP_SYSOUT
                        + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'.");
            }
        }
    }

    String logSysErrConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSERR);
    if (Boolean.valueOf(logSysErrConfiguration)) {
        delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr,
                LOGGER_NAME_SYSERR_DELEGATE);
        sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR);

        System.setErr(wrapPrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor,
                configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR));
    } else {
        if (Boolean.FALSE.toString().equals(logSysErrConfiguration)) {
            if (delegatingSysErrRegistration != null) {
                registrationTracker.unregister(delegatingSysErrRegistration);
                delegatingSysErrRegistration = null;
            }
            if (sysErrRegistration != null) {
                registrationTracker.unregister(sysErrRegistration);
                sysErrRegistration = null;
            }
            System.setErr((PrintStream) delegatingSysErr);
        } else {
            delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr,
                    LOGGER_NAME_SYSERR_DELEGATE);
            sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR);

            System.setErr(decoratePrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor,
                    configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR));

            if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysErrConfiguration)) {
                System.err.println("Invalid value '" + logSysErrConfiguration + "' for configuration key '"
                        + ConfigurationProvider.KEY_LOG_WRAP_SYSERR
                        + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'.");
            }
        }
    }

    if (Boolean.valueOf((String) configuration.get(ConfigurationProvider.KEY_ENABLE_JUL_CONSOLE_HANDLER))) {
        enableJulConsoleLogger();
    } else {
        disableJulConsoleHandler();
    }
}

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

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 .jav  a  2  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.archive.io.arc.ARCWriterTest.java

protected void lengthTooLong(String name, boolean compress, boolean strict) throws IOException {
    ARCWriter writer = createArcWithOneRecord(name, compress);
    // Add a record with a length that is too long.
    String content = getContent();
    writeRecord(writer, SOME_URL + "2", "text/html", content.length() + 10, getBais(content));
    writeRecord(writer, SOME_URL + "3", "text/html", content.length(), getBais(content));
    writer.close();/*from  w  ww  .j av a  2  s  .co  m*/

    // Catch System.err.
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    PrintStream origErr = System.err;
    ARCReader r = null;
    try {
        System.setErr(new PrintStream(os));

        r = ARCReaderFactory.get(writer.getFile());
        r.setStrict(strict);
        int count = iterateRecords(r);
        assertTrue("Count wrong " + count, count == 4);

        // Make sure we get the warning string which complains about the
        // trailing bytes.
        String err = os.toString();
        assertTrue("No message " + err, err.startsWith("WARNING Premature EOF before end-of-record"));
    } finally {
        Closeables.close(r, true);
        System.setErr(origErr);
    }
}

From source file:org.rhq.bundle.ant.AntMain.java

/**
 * Process command line arguments.//from w  ww  .  j  a v a2 s .com
 * When ant is started from Launcher, launcher-only arguments do not get
 * passed through to this routine.
 *
 * @param args the command line arguments.
 *
 * @since Ant 1.6
 */
private void processArgs(String[] args) {
    String searchForThis = null;
    boolean searchForFile = false;
    PrintStream logTo = null;

    // cycle through given args

    boolean justPrintUsage = false;
    boolean justPrintVersion = false;
    boolean justPrintDiagnostics = false;

    for (int i = 0; i < args.length; i++) {
        String arg = args[i];

        if (arg.equals("-help") || arg.equals("-h")) {
            justPrintUsage = true;
        } else if (arg.equals("-version")) {
            justPrintVersion = true;
        } else if (arg.equals("-diagnostics")) {
            justPrintDiagnostics = true;
        } else if (arg.equals("-quiet") || arg.equals("-q")) {
            msgOutputLevel = Project.MSG_WARN;
        } else if (arg.equals("-verbose") || arg.equals("-v")) {
            msgOutputLevel = Project.MSG_VERBOSE;
        } else if (arg.equals("-debug") || arg.equals("-d")) {
            msgOutputLevel = Project.MSG_DEBUG;
        } else if (arg.equals("-noinput")) {
            allowInput = false;
        } else if (arg.equals("-logfile") || arg.equals("-l")) {
            try {
                File logFile = new File(args[i + 1]);
                i++;
                logTo = new PrintStream(new FileOutputStream(logFile));
                isLogFileUsed = true;
            } catch (IOException ioe) {
                String msg = "Cannot write on the specified log file. "
                        + "Make sure the path exists and you have write " + "permissions.";
                throw new BuildException(msg);
            } catch (ArrayIndexOutOfBoundsException aioobe) {
                String msg = "You must specify a log file when " + "using the -log argument";
                throw new BuildException(msg);
            }
        } else if (arg.equals("-listener")) {
            i = handleArgListener(args, i);
        } else if (arg.startsWith("-D")) {
            i = handleArgDefine(args, i);
        } else if (arg.equals("-logger")) {
            i = handleArgLogger(args, i);
        } else if (arg.equals("-inputhandler")) {
            i = handleArgInputHandler(args, i);
        } else if (arg.equals("-emacs") || arg.equals("-e")) {
            emacsMode = true;
        } else if (arg.equals("-projecthelp") || arg.equals("-p")) {
            // set the flag to display the targets and quit
            projectHelp = true;
        } else if (arg.startsWith("-propertyfile")) {
            i = handleArgPropertyFile(args, i);
        } else if (arg.equals("-k") || arg.equals("-keep-going")) {
            keepGoingMode = true;
        } else if (arg.equals("-nice")) {
            i = handleArgNice(args, i);
        } else if (LAUNCH_COMMANDS.contains(arg)) {
            //catch script/ant mismatch with a meaningful message
            //we could ignore it, but there are likely to be other
            //version problems, so we stamp down on the configuration now
            String msg = "Ant's Main method is being handed " + "an option " + arg
                    + " that is only for the launcher class."
                    + "\nThis can be caused by a version mismatch between "
                    + "the ant script/.bat file and Ant itself.";
            throw new BuildException(msg);
        } else if (arg.equals("-autoproxy")) {
            proxy = true;
        } else if (arg.startsWith("-")) {
            // we don't have any more args to recognize!
            String msg = "Unknown argument: " + arg;
            System.err.println(msg);
            printUsage();
            throw new BuildException("");
        } else {
            // if it's no other arg, it may be the target
            targets.addElement(arg);
        }
    }

    if (msgOutputLevel >= Project.MSG_VERBOSE || justPrintVersion) {
        printVersion(msgOutputLevel);
    }

    if (justPrintUsage || justPrintVersion || justPrintDiagnostics) {
        if (justPrintUsage) {
            printUsage();
        }
        if (justPrintDiagnostics) {
            Diagnostics.doReport(System.out, msgOutputLevel);
        }
        return;
    }

    // RHQ: The build file is not configurable - it's always ./rhq-bundle.xml.
    buildFile = new File(BUILD_FILE_NAME);

    // make sure buildfile exists
    if (!buildFile.exists()) {
        System.out.println("Buildfile: " + buildFile + " does not exist!");
        throw new BuildException("Build failed");
    }

    // make sure it's not a directory (this falls into the ultra
    // paranoid lets check everything category

    if (buildFile.isDirectory()) {
        System.out.println("What? Buildfile: " + buildFile + " is a dir!");
        throw new BuildException("Build failed");
    }

    // Normalize buildFile for re-import detection
    buildFile = FileUtils.getFileUtils().normalize(buildFile.getAbsolutePath());

    // Load the property files specified by -propertyfile
    loadPropertyFiles();

    if (msgOutputLevel >= Project.MSG_INFO) {
        System.out.println("Buildfile: " + buildFile);
    }

    if (logTo != null) {
        out = logTo;
        err = logTo;
        System.setOut(out);
        System.setErr(err);
    }
    readyToRun = true;
}

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

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  ava 2 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());

        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.apache.maven.cli.MavenCli.java

/**
 * configure logging//from w  ww.  ja  va  2 s  .  co  m
 */
private void logging(CliRequest cliRequest) {
    cliRequest.debug = cliRequest.commandLine.hasOption(CLIManager.DEBUG);
    cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption(CLIManager.QUIET);
    cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption(CLIManager.ERRORS);

    slf4jLoggerFactory = LoggerFactory.getILoggerFactory();
    Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration(slf4jLoggerFactory);

    if (cliRequest.debug) {
        cliRequest.request.setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_DEBUG);
        slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.DEBUG);
    } else if (cliRequest.quiet) {
        cliRequest.request.setLoggingLevel(MavenExecutionRequest.LOGGING_LEVEL_ERROR);
        slf4jConfiguration.setRootLoggerLevel(Slf4jConfiguration.Level.ERROR);
    }
    // else fall back to default log level specified in conf
    // see https://issues.apache.org/jira/browse/MNG-2570

    if (cliRequest.commandLine.hasOption(CLIManager.LOG_FILE)) {
        File logFile = new File(cliRequest.commandLine.getOptionValue(CLIManager.LOG_FILE));
        logFile = resolveFile(logFile, cliRequest.workingDirectory);

        // redirect stdout and stderr to file
        try {
            PrintStream ps = new PrintStream(new FileOutputStream(logFile));
            System.setOut(ps);
            System.setErr(ps);
        } catch (FileNotFoundException e) {
            //
            // Ignore
            //
        }
    }

    slf4jConfiguration.activate();

    plexusLoggerManager = new Slf4jLoggerManager();
    slf4jLogger = slf4jLoggerFactory.getLogger(this.getClass().getName());
}

From source file:net.sourceforge.pmd.lang.xml.XmlParserTest.java

/**
 * Verifies the parsing behavior of the XML parser with validation on.
 * /*from   ww  w.ja v  a2  s  .  c o m*/
 * @throws UnsupportedEncodingException
 *             error
 */
@Test
public void testParsingWithValidation() throws UnsupportedEncodingException {
    LanguageVersionHandler xmlVersionHandler = LanguageRegistry.getLanguage(XmlLanguageModule.NAME)
            .getDefaultVersion().getLanguageVersionHandler();
    XmlParserOptions parserOptions = new XmlParserOptions();
    parserOptions.setValidating(true);
    Parser parser = xmlVersionHandler.getParser(parserOptions);
    PrintStream oldErr = System.err;
    Locale oldLocale = Locale.getDefault();
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        System.setErr(new PrintStream(bos));
        Locale.setDefault(Locale.ENGLISH);
        Node document = parser.parse(null, new StringReader(XML_INVALID_WITH_DTD));
        Assert.assertNotNull(document);
        String output = bos.toString("UTF-8");
        Assert.assertTrue(output.contains("Element type \"invalidChild\" must be declared."));
        Assert.assertTrue(
                output.contains("The content of element type \"rootElement\" must match \"(child)\"."));
        Assert.assertEquals(2, document.jjtGetNumChildren());
        Assert.assertEquals("invalidChild", String.valueOf(document.jjtGetChild(1).jjtGetChild(1)));
    } finally {
        System.setErr(oldErr);
        Locale.setDefault(oldLocale);
    }
}

From source file:com.cisco.dvbu.ps.deploytool.dao.wsapi.VCSWSDAOImpl.java

public void vcsDiffMergerCommand(String prefix, String arguments, String vcsIgnoreMessages, String propertyFile)
        throws CompositeException {

    String identifier = "VCSWSDAOImpl.vcsDiffMergerCommand"; // some unique identifier that characterizes this invocation.
    String actionName = "DIFF";

    try {//from   www .java2s . c om
        boolean preserveQuotes = false;
        boolean initArgsList = true;
        List<String> argsList = new ArrayList<String>();
        argsList = CommonUtils.parseArguments(argsList, initArgsList, arguments, preserveQuotes, propertyFile);

        String[] args = argsList.toArray(new String[0]);

        /*
         * 2014-06-30 (mtinius): Removed the PDTool Diffmerger capability
         */
        //         DiffMerger.startCommand(null, null, args);
        /*
         * 2014-06-30 (mtinius): Added security manager around the Composite native Diffmerger code because
         *                    it has System.out.println and System.exit commands.  Need to trap both.
         */
        String maskedargsList = CommonUtils.getArgumentListMasked(argsList);
        if (logger.isDebugEnabled()) {
            logger.debug(identifier + "(prefix, arguments, vcsIgnoreMessages, propertyFile).  prefix=" + prefix
                    + "  arguments=[" + maskedargsList + "]" + "  vcsIgnoreMessages=" + vcsIgnoreMessages
                    + "  propertyFile=" + propertyFile);
        }

        // Get the existing security manager
        SecurityManager sm = System.getSecurityManager();
        PrintStream originalOut = System.out;
        PrintStream originalErr = System.err;
        String command = "DiffMerger.startCommand";
        try {
            // Get the offset location of the java.policy file [offset from PDTool home].
            String javaPolicyOffset = CommonConstants.javaPolicy;
            String javaPolicyLocation = CommonUtils.extractVariable(prefix,
                    CommonUtils.getFileOrSystemPropertyValue(propertyFile, "PROJECT_HOME_PHYSICAL"),
                    propertyFile, true) + javaPolicyOffset;
            // Set the java security policy
            System.getProperties().setProperty("java.security.policy", javaPolicyLocation);

            // Create a new System.out Logger
            Logger exportLogger = Logger.getLogger(DiffMerger.class);
            System.setOut(new PrintStream(new LogOutputStream(exportLogger, Level.INFO)));
            System.setErr(new PrintStream(new LogOutputStream(exportLogger, Level.ERROR)));
            // Create a new security manager
            System.setSecurityManager(new NoExitSecurityManager());

            // Don't execute if -noop (NO_OPERATION) has been set otherwise execute under normal operation.
            if (CommonUtils.isExecOperation()) {
                // Invoke the Composite native DiffMerger command.
                DiffMerger.startCommand(null, null, args);
            } else {
                logger.info("\n\nWARNING - NO_OPERATION: COMMAND [" + command + "], ACTION [" + actionName
                        + "] WAS NOT PERFORMED.\n");
            }
        } catch (NoExitSecurityExceptionStatusNonZero nesesnz) {
            String error = identifier + ":: Exited with exception from System.exit(): " + command
                    + "(null, null, " + maskedargsList + ")";
            logger.error(error);
            throw new CompositeException(error);
        } catch (NoExitSecurityExceptionStatusZero nesezero) {
            if (logger.isDebugEnabled()) {
                logger.debug(identifier + ":: Exited successfully from System.exit(): " + command
                        + "(null, null, " + maskedargsList + ")");
            }
        } finally {
            System.setSecurityManager(sm);
            System.setOut(originalOut);
            System.setErr(originalErr);
        }

    } catch (Exception e) {
        if (resolveExecCommandLineError(prefix, e.getMessage().toString(), vcsIgnoreMessages)) {
            ApplicationException applicationException = new ApplicationException(
                    "DiffMerger execution returned an error=" + e.getMessage().toString());
            if (logger.isErrorEnabled()) {
                logger.error(applicationException);
            }
            throw applicationException;
        }
    }
}

From source file:org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.java

private static void redirectStandardStreams() throws FileNotFoundException {
    in = System.in;/*from ww w.j a  v a 2s.c o m*/
    out = System.out;
    err = System.err;
    System.setIn(new ByteArrayInputStream(new byte[0]));
    boolean isDebug = Boolean.getBoolean("jdt.ls.debug");
    if (isDebug) {
        String id = "jdt.ls-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        File workspaceFile = root.getRawLocation().makeAbsolute().toFile();
        File rootFile = new File(workspaceFile, ".metadata");
        rootFile.mkdirs();
        File outFile = new File(rootFile, ".out-" + id + ".log");
        FileOutputStream stdFileOut = new FileOutputStream(outFile);
        System.setOut(new PrintStream(stdFileOut));
        File errFile = new File(rootFile, ".error-" + id + ".log");
        FileOutputStream stdFileErr = new FileOutputStream(errFile);
        System.setErr(new PrintStream(stdFileErr));
    } else {
        System.setOut(new PrintStream(new ByteArrayOutputStream()));
        System.setErr(new PrintStream(new ByteArrayOutputStream()));
    }
}

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

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  ww .j a va 2s . 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());

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