Example usage for java.lang System setOut

List of usage examples for java.lang System setOut

Introduction

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

Prototype

public static void setOut(PrintStream out) 

Source Link

Document

Reassigns the "standard" output stream.

Usage

From source file:com.proteus.jsmodify.JSExecutionTracer.java

/**
 * Dirty way to save program points from the proxy request threads. TODO: Frank, find cleaner
 * way.//from  w ww.j  a v  a  2  s .c  o  m
 * 
 * @param string
 *            The JSON-text to save.
 */
public static void addPoint(String string) {
    JSONArray buffer = null;
    JSONObject targetAttributes = null;
    JSONObject targetElement = null;
    String JSONLabel = new String();
    int i;

    try {
        /* save the current System.out for later usage */
        PrintStream oldOut = System.out;
        /* redirect it to the file */
        System.setOut(output);

        buffer = new JSONArray(string);
        for (i = 0; i < buffer.length(); i++) {

            if (points.length() > 0) {
                // Add comma after previous trace object
                System.out.println(",");
            }

            points.put(buffer.getJSONObject(i));

            if (buffer.getJSONObject(i).has("args")
                    && ((String) buffer.getJSONObject(i).get("messageType")).contains("FUNCTION_ENTER")) {
                try {
                    JSONArray args = (JSONArray) buffer.getJSONObject(i).get("args");
                    String newValue = args.toString();
                    buffer.getJSONObject(i).remove("args");
                    buffer.getJSONObject(i).put("args", newValue);
                } catch (JSONException jse) {
                    // argument is not a JSON object
                    continue;
                }
            }
            if (buffer.getJSONObject(i).has("returnValue")
                    && !buffer.getJSONObject(i).get("returnValue").getClass().toString().contains("Null")) {
                try {
                    JSONObject rv = (JSONObject) buffer.getJSONObject(i).get("returnValue");
                    String newValue = rv.toString();
                    buffer.getJSONObject(i).remove("returnValue");
                    buffer.getJSONObject(i).put("returnValue", newValue);
                } catch (JSONException jse) {
                    // argument is not a JSON object
                    continue;
                }
            }
            if (buffer.getJSONObject(i).has("targetElement")) {
                JSONArray extractedArray = new JSONArray(
                        buffer.getJSONObject(i).get("targetElement").toString());
                try {
                    targetAttributes = extractedArray.getJSONObject(1);
                    String targetType = extractedArray.get(0).toString();

                    targetElement = new JSONObject("{\"elementType\":\"" + targetType + "\",\"attributes\":"
                            + targetAttributes.toString() + "}");

                } catch (Exception e) {
                    // targetElement is not usual DOM element
                    // E.g. DOMContentLoaded
                    if (buffer.getJSONObject(i).has("eventType")
                            && buffer.getJSONObject(i).get("eventType").toString().contains("ContentLoaded")) {
                        targetElement = new JSONObject("{\"elementType\":\"DOCUMENT\",\"attributes\":\"-\"}");
                    } else {
                        targetElement = new JSONObject("{\"elementType\":\"UNKNOWN\",\"attributes\":\"-\"}");
                    }
                }
                buffer.getJSONObject(i).remove("targetElement");
                buffer.getJSONObject(i).put("targetElement", targetElement.toString());
            }

            // Insert @class key for Jackson mapping
            if (buffer.getJSONObject(i).has("messageType")) {
                String mType = buffer.getJSONObject(i).get("messageType").toString();

                // Maybe better to change mType to ENUM and use switch
                // instead of 'if's
                if (mType.contains("FUNCTION_CALL")) {
                    buffer.getJSONObject(i).put("@class", "com.proteus.core.trace.FunctionCall");
                    JSONLabel = "\"FunctionTrace\":";
                } else if (mType.contains("FUNCTION_ENTER")) {
                    buffer.getJSONObject(i).put("@class", "com.proteus.core.trace.FunctionEnter");
                    JSONLabel = "\"FunctionTrace\":";
                } else if (mType.contains("FUNCTION_EXIT")) {
                    buffer.getJSONObject(i).put("@class", "com.proteus.core.trace.FunctionExit");
                    JSONLabel = "\"FunctionTrace\":";
                } else if (mType.contains("RETURN_STATEMENT")) {
                    buffer.getJSONObject(i).put("@class", "com.proteus.core.trace.FunctionReturnStatement");
                    JSONLabel = "\"FunctionTrace\":";
                } else if (mType.contains("DOM_EVENT")) {
                    buffer.getJSONObject(i).put("@class", "com.proteus.core.trace.DOMEventTrace");
                    JSONLabel = "\"DOMEventTrace\":";
                } /* else if (mType.contains("DOM_MUTATION")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.DOMMutationTrace");
                  JSONLabel = "\"DOMEventTrace\":";
                  } else if (mType.contains("DOM_ELEMENT_VALUE")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.DOMElementValueTrace");
                  JSONLabel = "\"DOMEventTrace\":";
                  } else if (mType.contains("TIMEOUT_SET")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.TimeoutSet");
                  JSONLabel = "\"TimingTrace\":";
                  } else if (mType.contains("TIMEOUT_CALLBACK")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.TimeoutCallback");
                  JSONLabel = "\"TimingTrace\":";
                  } else if (mType.contains("XHR_OPEN")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.XMLHttpRequestOpen");
                  JSONLabel = "\"XHRTrace\":";
                  } else if (mType.contains("XHR_SEND")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.XMLHttpRequestSend");
                  JSONLabel = "\"XHRTrace\":";
                  } else if (mType.contains("XHR_RESPONSE")) {
                  buffer.getJSONObject(i).put("@class",
                          "com.clematis.core.trace.XMLHttpRequestResponse");
                  JSONLabel = "\"XHRTrace\":";
                  }
                  */
                // messageType obsolete
                buffer.getJSONObject(i).remove("messageType");
            }

            System.out.print(JSONLabel + "[" + buffer.getJSONObject(i).toString(2) + "]");
        }

        /* Restore the old system.out */
        System.setOut(oldOut);

        if (i > 0) {
            counter = buffer.getJSONObject(buffer.length() - 1).getInt("counter") + 1;
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }

}

From source file:fur.shadowdrake.minecraft.InstallPanel.java

private boolean doPostDownload() throws NetworkException {
    boolean b;/*from  w  ww.  java 2s . c  o m*/
    PrintStream originalOut = System.out;
    log.setIndeterminate();
    log.setStatusText("running post-download");
    System.setOut(new PrintStream(new OutputStream() {
        @Override
        public void write(int b) throws IOException {
            byte[] x = new byte[1];
            x[0] = (byte) b;
            log.print(new String(x));
        }

        @Override
        public void write(byte[] b, int off, int len) throws IOException {
            log.print(new String(b, off, len));
        }
    }));
    try {
        URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { new File(workingDir).toURI().toURL() });
        Class postDownloadClass = urlClassLoader.loadClass("PostDownload");
        Constructor constructor = postDownloadClass.getConstructor();
        Object pd = constructor.newInstance();
        Method method = postDownloadClass.getMethod("invoke", new Class[] { String.class, String.class });
        b = (boolean) method.invoke(pd, config.getInstallDir().getAbsolutePath(), workingDir);
        if (b) {
            showReadMe();
        }
        return b;
    } catch (MalformedURLException | ClassNotFoundException | NoSuchMethodException | SecurityException
            | InstantiationException | IllegalAccessException | IllegalArgumentException
            | InvocationTargetException | NoClassDefFoundError ex) {
        Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex);
        log.println("Executing post-download failed.");
    } finally {
        System.setOut(originalOut);
        log.reset();
    }
    return false;
}

From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java

private JComponent createConsolePanel() {
    JTextArea consoleArea = new JTextArea();
    consoleArea.setToolTipText("General progress information");
    consoleArea.setEditable(false);/* ww w  . jav  a 2 s  .c  om*/
    Console console = new Console();
    console.setTextArea(consoleArea);
    System.setOut(new PrintStream(console));
    System.setErr(new PrintStream(console));
    JScrollPane consoleScrollPane = new JScrollPane(consoleArea);
    consoleScrollPane.setBorder(BorderFactory.createTitledBorder("Console"));
    consoleScrollPane.setPreferredSize(new Dimension(800, 200));
    consoleScrollPane.setAutoscrolls(true);
    ObjectExchange.console = console;
    return consoleScrollPane;
}

From source file:org.exist.launcher.Launcher.java

/**
 * Ensure that stdout and stderr messages are also printed
 * to the logs./*from  w w  w  .ja  v  a  2s  . c om*/
 */
private void captureConsole() {
    System.setOut(createLoggingProxy(System.out));
    System.setErr(createLoggingProxy(System.err));
}

From source file:org.apache.sentry.cli.tools.TestSentryShellHive.java

private Set<String> getShellResultWithOSRedirect(SentryShellHive sentryShell, String[] args,
        boolean exceptedExecuteResult) throws Exception {
    PrintStream oldOut = System.out;
    ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    System.setOut(new PrintStream(outContent));
    assertEquals(exceptedExecuteResult, sentryShell.executeShell(args));
    Set<String> resultSet = Sets.newHashSet(outContent.toString().split("\n"));
    System.setOut(oldOut);//from  w w w.j a va2  s  .c  o  m
    return resultSet;
}

From source file:org.hyperic.hq.agent.server.AgentDaemon.java

private void redirectStreams(Properties props) {
    //redirect System.{out,err} to log4j appender
    PrintStream stream;//  w  w  w  . jav a  2 s.  c o m
    if ((stream = newLogStream("SystemOut", props)) != null) {
        System.setOut(stream);
    }
    if ((stream = newLogStream("SystemErr", props)) != null) {
        System.setErr(stream);
    }
}

From source file:org.hammurapi.TaskBase.java

/**
 * @param options//from ww  w . j  a  va  2 s.  c om
 * @param line
 * @param task
 * @param project
 */
protected void configure(Options options, CommandLine line) {
    String[] largs = line.getArgs();
    if (largs.length == 0) {
        System.out.println("Output dir has to be provided");
        printHelpAndExit(options);
    }

    if (!line.hasOption('o')) {
        new File(largs[0]).mkdirs();
        Output output = createOutput();
        output.setDir(largs[0]);

        if (line.hasOption('x')) {
            output.setEmbeddedStyle(false);
            output.setExtension(".xml");
        }
    }

    if (largs.length == 1 && !line.hasOption('A')) {
        System.out.println("At least one source directory or archive must be provided");
        printHelpAndExit(options);
    }

    if (line.hasOption('y')) {
        setReviewDescription(line.getOptionValue('y'));
    }

    for (int i = 1; i < largs.length; i++) {
        File file = new File(largs[i]);
        if (file.isFile()) {
            srcFiles.add(file);
        } else if (file.isDirectory()) {
            createSrc().setDir(file);
        }
    }

    String[] values = line.getOptionValues('c');
    for (int i = 0; values != null && i < values.length; i++) {
        createClasspath().append(new Path(project, values[i]));
    }

    values = line.getOptionValues('m');
    for (int i = 0; values != null && i < values.length; i++) {
        createConfig().setFile(new File(values[i]));
    }

    values = line.getOptionValues('q');
    for (int i = 0; values != null && i < values.length; i++) {
        createConfig().setURL(values[i]);
    }

    values = line.getOptionValues('I');
    for (int i = 0; values != null && i < values.length; i++) {
        InspectorEntry ie = createInspector();
        ie.setName(values[i]);
        ie.setEnabled(true);
    }

    values = line.getOptionValues('X');
    for (int i = 0; values != null && i < values.length; i++) {
        InspectorEntry ie = createInspector();
        ie.setName(values[i]);
        ie.setEnabled(false);
    }

    setEvictBadInspectors(line.hasOption('E'));

    setEmbeddedInspectors(!line.hasOption('e'));

    if (line.hasOption('t')) {
        setDebugType(line.getOptionValue('t'));
    }

    if (line.hasOption('r')) {
        setUnpackDir(new File(line.getOptionValue('r')));
    }

    if (line.hasOption('T')) {
        setTitle(line.getOptionValue('T'));
    }

    BuildLogger logger = new DefaultLogger();
    logger.setMessageOutputLevel(Project.MSG_INFO);
    logger.setOutputPrintStream(System.out);
    logger.setErrorPrintStream(System.err);
    logger.setEmacsMode(false);

    if (line.hasOption('v')) {
        logger.setMessageOutputLevel(Project.MSG_VERBOSE);
    }

    if (line.hasOption('g')) {
        logger.setMessageOutputLevel(Project.MSG_DEBUG);
    }

    project.addBuildListener(logger);

    System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
    System.setErr(new PrintStream(new DemuxOutputStream(project, true)));

    if (line.hasOption('w')) {
        setWaiverStubs(new File(line.getOptionValue('w')));
    }

    if (line.hasOption('s')) {
        setSigmaThreshold(Double.parseDouble(line.getOptionValue('s')));
    }

    if (line.hasOption('d')) {
        setDpmoThreshold(Integer.parseInt(line.getOptionValue('d')));
    }

    if (line.hasOption('S')) {
        setSeverityThreshold(Integer.parseInt(line.getOptionValue('S')));
    }

    if (line.hasOption('f')) {
        setForce(true);
    }

    if (line.hasOption('k')) {
        setForceOnWarnings(false);
    }

    if (line.hasOption('D')) {
        setDatabase(new File(line.getOptionValue('D')));
    }

    values = line.getOptionValues('i');
    for (int i = 0; values != null && i < values.length; i++) {
        createInspectors().setFile(new File(values[i]));
    }

    values = line.getOptionValues('u');
    for (int i = 0; values != null && i < values.length; i++) {
        createInspectors().setURL(values[i]);
    }

    values = line.getOptionValues('l');
    for (int i = 0; values != null && i < values.length; i++) {
        ListenerEntry listenerEntry = new ListenerEntry();
        listenerEntry.setClassName(values[i]);
        addConfiguredListener(listenerEntry);
    }

    values = line.getOptionValues('W');
    for (int i = 0; values != null && i < values.length; i++) {
        createWaivers().setFile(new File(values[i]));
    }

    values = line.getOptionValues('U');
    for (int i = 0; values != null && i < values.length; i++) {
        createWaivers().setURL(values[i]);
    }

    if (line.hasOption('A')) {
        setArchive(new File(line.getOptionValue('A')));
    }

    //Anu 20050701 : baselining
    if (line.hasOption('B')) {
        setBaselining(line.getOptionValue('B'));
    }
}

From source file:org.finra.herd.tools.common.databridge.AbstractDataBridgeTest.java

protected String runTestGetSystemOut(Runnable runnable) {
    try {//from   w  w  w  .  jav a 2  s.c  o  m
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(output);
        System.setOut(printStream);
        runnable.run();

        return output.toString().trim();
    } finally {
        System.setOut(originalStream);
    }
}

From source file:com.adobe.aem.demomachine.gui.AemDemo.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private void initialize() {

    // Initialize properties
    setDefaultProperties(AemDemoUtils//from   ww w .ja  va  2s  . c  o  m
            .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"));
    setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath()
            + File.separator + "conf" + File.separator + "build-personal.properties"));

    // Constructing the main frame
    frameMain = new JFrame();
    frameMain.setBounds(100, 100, 700, 530);
    frameMain.getContentPane().setLayout(null);

    // Main menu bar for the Frame
    JMenuBar menuBar = new JMenuBar();

    JMenu mnAbout = new JMenu("AEM Demo Machine");
    mnAbout.setMnemonic(KeyEvent.VK_A);
    menuBar.add(mnAbout);

    JMenuItem mntmUpdates = new JMenuItem("Check for Updates");
    mntmUpdates.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "demo_update");
        }
    });
    mnAbout.add(mntmUpdates);

    JMenuItem mntmDoc = new JMenuItem("Help and Documentation");
    mntmDoc.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmDoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOCUMENTATION));
        }
    });
    mnAbout.add(mntmDoc);

    JMenuItem mntmScripts = new JMenuItem("Demo Scripts (VPN)");
    mntmScripts.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_SCRIPTS));
        }
    });
    mnAbout.add(mntmScripts);

    JMenuItem mntmDiagnostics = new JMenuItem("Diagnostics");
    mntmDiagnostics.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Map<String, String> env = System.getenv();
            System.out.println("====== System Environment Variables ======");
            for (String envName : env.keySet()) {
                System.out.format("%s=%s%n", envName, env.get(envName));
            }
            System.out.println("====== JVM Properties ======");
            RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
            List<String> jvmArgs = runtimeMXBean.getInputArguments();
            for (String arg : jvmArgs) {
                System.out.println(arg);
            }
            System.out.println("====== Runtime Properties ======");
            Properties props = System.getProperties();
            props.list(System.out);
        }
    });
    mnAbout.add(mntmDiagnostics);

    JMenuItem mntmQuit = new JMenuItem("Quit");
    mntmQuit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    mnAbout.add(mntmQuit);

    JMenu mnNew = new JMenu("New");
    menuBar.add(mnNew);

    // New Demo Machine
    JMenuItem mntmNewDemo = new JMenuItem("Demo Environment");
    mntmNewDemo.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewDemo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (AemDemo.this.getBuildInProgress()) {

                JOptionPane.showMessageDialog(null,
                        "A Demo Environment is currently being built. Please wait until it is finished.");

            } else {

                final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this);
                dialogNew.setModal(true);
                dialogNew.setVisible(true);
                dialogNew.getDemoBuildName().requestFocus();
                ;

            }
        }
    });
    mnNew.add(mntmNewDemo);

    JMenuItem mntmNewOptions = new JMenuItem("Demo Properties");
    mntmNewOptions.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewOptions.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this);
            dialogOptions.setModal(true);
            dialogOptions.setVisible(true);

        }
    });
    mnNew.add(mntmNewOptions);

    JMenu mnUpdate = new JMenu("Add-ons");
    menuBar.add(mnUpdate);

    // Sites Add-on
    JMenu mnSites = new JMenu("Sites");
    mnUpdate.add(mnSites);

    JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Demo Add-on");
    mntmSitesDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites");
        }
    });
    mnSites.add(mntmSitesDownloadAddOn);

    JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Packages (PackageShare)");
    mntmSitesDownloadFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites_packages");
        }
    });
    mnSites.add(mntmSitesDownloadFP);

    // Assets Add-on
    JMenu mnAssets = new JMenu("Assets");
    mnUpdate.add(mnAssets);

    JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Demo Add-on");
    mntmAssetsDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_assets");
        }
    });
    mnAssets.add(mntmAssetsDownloadAddOn);

    JMenuItem mntmAssetsDownloadFP = new JMenuItem("Download Packages (PackageShare)");
    mntmAssetsDownloadFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_assets_packages");
        }
    });
    mnAssets.add(mntmAssetsDownloadFP);

    // Communities Add-on
    JMenu mnCommunities = new JMenu("Communities/Livefyre");
    mnUpdate.add(mnCommunities);

    JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Packages (PackageShare)");
    mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_communities_packages");
        }
    });
    mnCommunities.add(mntmAemCommunitiesFeaturePacks);

    // Forms Add-on
    JMenu mnForms = new JMenu("Forms");
    mnUpdate.add(mnForms);

    JMenuItem mntmAemFormsAddon = new JMenuItem("Download Demo Add-on");
    mntmAemFormsAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_forms");
        }
    });
    mnForms.add(mntmAemFormsAddon);

    JMenuItem mntmAemFormsFP = new JMenuItem("Download Packages (PackageShare)");
    mntmAemFormsFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_forms_packages");
        }
    });
    mnForms.add(mntmAemFormsFP);

    // Mobile Add-on
    JMenu mnApps = new JMenu("Mobile");
    mnUpdate.add(mnApps);

    JMenuItem mntmAemAppsAddon = new JMenuItem("Download Demo Add-on");
    mntmAemAppsAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_apps");
        }
    });
    mnApps.add(mntmAemAppsAddon);

    JMenuItem mntmAemApps = new JMenuItem("Download Packages (PackageShare)");
    mntmAemApps.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_apps_packages");
        }
    });
    mnApps.add(mntmAemApps);

    // Commerce Add-on
    JMenu mnCommerce = new JMenu("Commerce");
    mnUpdate.add(mnCommerce);

    JMenu mnCommerceDownload = new JMenu("Download Packages");
    mnCommerce.add(mnCommerceDownload);

    // Commerce EP
    JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath (PackageShare)");
    mnCommerceDownloadEP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadEP);

    // Commerce WebSphere
    JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere (PackageShare)");
    mnCommerceDownloadWAS.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadWAS);

    // WeRetail Add-on
    JMenu mnWeRetail = new JMenu("We-Retail");
    mnUpdate.add(mnWeRetail);

    JMenuItem mnWeRetailAddon = new JMenuItem("Download Demo Add-on");
    mnWeRetailAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_weretail");
        }
    });
    mnWeRetail.add(mnWeRetailAddon);

    // Download all section
    mnUpdate.addSeparator();

    JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons");
    mntmAemDownloadAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_all");
        }
    });
    mnUpdate.add(mntmAemDownloadAll);

    JMenu mnInfrastructure = new JMenu("Infrastructure");
    menuBar.add(mnInfrastructure);

    JMenu mnMongo = new JMenu("MongoDB");

    JMenuItem mntmInfraMongoDB = new JMenuItem("Download");
    mntmInfraMongoDB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDB);

    JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install");
    mntmInfraMongoDBInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDBInstall);
    mnMongo.addSeparator();

    JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start");
    mntmInfraMongoDBStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_start");
        }
    });
    mnMongo.add(mntmInfraMongoDBStart);

    JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop");
    mntmInfraMongoDBStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_stop");
        }
    });
    mnMongo.add(mntmInfraMongoDBStop);
    mnInfrastructure.add(mnMongo);

    // SOLR options
    JMenu mnSOLR = new JMenu("SOLR");

    JMenuItem mntmInfraSOLR = new JMenuItem("Download");
    mntmInfraSOLR.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLR);

    JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install");
    mntmInfraSOLRInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLRInstall);
    mnSOLR.addSeparator();

    JMenuItem mntmInfraSOLRStart = new JMenuItem("Start");
    mntmInfraSOLRStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_start");
        }
    });
    mnSOLR.add(mntmInfraSOLRStart);

    JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop");
    mntmInfraSOLRStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_stop");
        }
    });
    mnSOLR.add(mntmInfraSOLRStop);

    mnInfrastructure.add(mnSOLR);

    // MySQL options
    JMenu mnMySQL = new JMenu("MySQL");

    JMenuItem mntmInfraMysql = new JMenuItem("Download");
    mntmInfraMysql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysql);

    JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install");
    mntmInfraMysqlInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysqlInstall);

    mnMySQL.addSeparator();

    JMenuItem mntmInfraMysqlStart = new JMenuItem("Start");
    mntmInfraMysqlStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_start");
        }
    });
    mnMySQL.add(mntmInfraMysqlStart);

    JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop");
    mntmInfraMysqlStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_stop");
        }
    });
    mnMySQL.add(mntmInfraMysqlStop);

    mnInfrastructure.add(mnMySQL);

    // James options
    JMenu mnJames = new JMenu("James SMTP/POP");

    JMenuItem mntmInfraJames = new JMenuItem("Download");
    mntmInfraJames.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_james");
        }
    });
    mnJames.add(mntmInfraJames);

    JMenuItem mntmInfraJamesInstall = new JMenuItem("Install");
    mntmInfraJamesInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_james");
        }
    });
    mnJames.add(mntmInfraJamesInstall);
    mnJames.addSeparator();

    JMenuItem mntmInfraJamesStart = new JMenuItem("Start");
    mntmInfraJamesStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_start");
        }
    });
    mnJames.add(mntmInfraJamesStart);

    JMenuItem mntmInfraJamesStop = new JMenuItem("Stop");
    mntmInfraJamesStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_stop");
        }
    });
    mnJames.add(mntmInfraJamesStop);

    mnInfrastructure.add(mnJames);

    // FFMPEPG options
    JMenu mnFFMPEG = new JMenu("FFMPEG");

    JMenuItem mntmInfraFFMPEG = new JMenuItem("Download");
    mntmInfraFFMPEG.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEG);

    JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install");
    mntmInfraFFMPEGInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEGInstall);

    mnInfrastructure.add(mnFFMPEG);

    mnInfrastructure.addSeparator();

    // InDesignServer options
    JMenu mnInDesignServer = new JMenu("InDesign Server");

    JMenuItem mntmInfraInDesignServerDownload = new JMenuItem("Download");
    mntmInfraInDesignServerDownload.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerDownload);

    mnInDesignServer.addSeparator();

    JMenuItem mntmInfraInDesignServerStart = new JMenuItem("Start");
    mntmInfraInDesignServerStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "start_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerStart);

    JMenuItem mntmInfraInDesignServerStop = new JMenuItem("Stop");
    mntmInfraInDesignServerStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "stop_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerStop);

    mnInfrastructure.add(mnInDesignServer);

    mnInfrastructure.addSeparator();

    JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup");
    mntmInfraInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "infrastructure");
        }
    });
    mnInfrastructure.add(mntmInfraInstall);

    JMenu mnOther = new JMenu("Other");
    menuBar.add(mnOther);

    JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)");

    JMenuItem mntmAemLoad = new JMenuItem("Download Latest AEM Load");
    mntmAemLoad.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemLoad.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_load");
        }
    });
    mntmAemDownload.add(mntmAemLoad);

    JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot");
    mntmAemSnapshot.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemSnapshot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_snapshot");
        }
    });
    mntmAemDownload.add(mntmAemSnapshot);

    JMenuItem mntmAemDownloadAEM62 = new JMenuItem("Download AEM 6.2");
    mntmAemDownloadAEM62.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem62");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM62);

    JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1");
    mntmAemDownloadAEM61.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem61");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM61);

    JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0");
    mntmAemDownloadAEM60.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem60");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM60);

    JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1");
    mntmAemDownloadCQ561.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq561");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ561);

    JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6");
    mntmAemDownloadCQ56.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq56");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ56);

    JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files");
    mntmAemDownloadOthers.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOWNLOAD));
        }
    });
    mntmAemDownload.add(mntmAemDownloadOthers);

    mnOther.add(mntmAemDownload);

    JMenuItem mntmAemHotfix = new JMenuItem("Download Latest Hotfixes (PackageShare)");
    mntmAemHotfix.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemHotfix.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_hotfixes_packages");
        }
    });
    mnOther.add(mntmAemHotfix);

    JMenuItem mntmAemAcs = new JMenuItem("Download Latest ACS Commons and Tools");
    mntmAemAcs.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemAcs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_acs");
        }
    });
    mnOther.add(mntmAemAcs);

    // Adding the menu bar
    frameMain.setJMenuBar(menuBar);

    // Adding other form elements
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(24, 163, 650, 230);
    frameMain.getContentPane().add(scrollPane);

    final JTextArea textArea = new JTextArea("");
    textArea.setEditable(false);
    scrollPane.setViewportView(textArea);

    // List of demo machines available
    JScrollPane scrollDemoList = new JScrollPane();
    scrollDemoList.setBounds(24, 34, 208, 100);
    frameMain.getContentPane().add(scrollDemoList);
    listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath());
    listDemoMachines = new JList(listModelDemoMachines);
    listDemoMachines.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listDemoMachines.setSelectedIndex(AemDemoUtils.getSelectedIndex(listDemoMachines,
            this.getDefaultProperties(), this.getPersonalProperties(), AemDemoConstants.OPTIONS_BUILD_DEFAULT));
    scrollDemoList.setViewportView(listDemoMachines);

    // Capturing the output stream of ANT commands
    AemDemoOutputStream out = new AemDemoOutputStream(textArea);
    System.setOut(new PrintStream(out));

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "start");

        }
    });

    btnStart.setBounds(250, 29, 117, 29);
    frameMain.getContentPane().add(btnStart);

    // Set Start as the default button
    JRootPane rootPane = SwingUtilities.getRootPane(btnStart);
    rootPane.setDefaultButton(btnStart);

    JButton btnInfo = new JButton("Details");
    btnInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "details");

        }
    });
    btnInfo.setBounds(250, 59, 117, 29);
    frameMain.getContentPane().add(btnInfo);

    // Rebuild action
    JButton btnRebuild = new JButton("Rebuild");
    btnRebuild.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (AemDemo.this.getBuildInProgress()) {

                JOptionPane.showMessageDialog(null,
                        "A Demo Environment is currently being built. Please wait until it is finished.");

            } else {

                final AemDemoRebuild dialogRebuild = new AemDemoRebuild(AemDemo.this);
                dialogRebuild.setModal(true);
                dialogRebuild.setVisible(true);
                dialogRebuild.getDemoBuildName().requestFocus();
                ;

            }

        }
    });

    btnRebuild.setBounds(250, 89, 117, 29);
    frameMain.getContentPane().add(btnRebuild);

    // Stop action 
    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            int dialogResult = JOptionPane.showConfirmDialog(null,
                    "Are you sure you really want to stop the running instances?", "Warning",
                    JOptionPane.YES_NO_OPTION);
            if (dialogResult == JOptionPane.NO_OPTION) {
                return;
            }
            AemDemoUtils.antTarget(AemDemo.this, "stop");

        }
    });
    btnStop.setBounds(500, 29, 117, 29);
    frameMain.getContentPane().add(btnStop);

    JButton btnExit = new JButton("Exit");
    btnExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    btnExit.setBounds(550, 408, 117, 29);
    frameMain.getContentPane().add(btnExit);

    JButton btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText("");
        }
    });
    btnClear.setBounds(40, 408, 117, 29);
    frameMain.getContentPane().add(btnClear);

    JButton btnBackup = new JButton("Backup");
    btnBackup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "backup");
        }
    });
    btnBackup.setBounds(500, 59, 117, 29);
    frameMain.getContentPane().add(btnBackup);

    JButton btnRestore = new JButton("Restore");
    btnRestore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "restore");
        }
    });
    btnRestore.setBounds(500, 89, 117, 29);
    frameMain.getContentPane().add(btnRestore);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int dialogResult = JOptionPane.showConfirmDialog(null,
                    "Are you sure you really want to permanently delete the selected demo configuration?",
                    "Warning", JOptionPane.YES_NO_OPTION);
            if (dialogResult == JOptionPane.NO_OPTION) {
                return;
            }
            AemDemoUtils.antTarget(AemDemo.this, "uninstall");
        }
    });
    btnDelete.setBounds(500, 119, 117, 29);
    frameMain.getContentPane().add(btnDelete);

    JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment");
    lblSelectYourDemo.setBounds(24, 10, 219, 16);
    frameMain.getContentPane().add(lblSelectYourDemo);

    JLabel lblCommandOutput = new JLabel("Command Output");
    lblCommandOutput.setBounds(24, 143, 160, 16);
    frameMain.getContentPane().add(lblCommandOutput);

    // Initializing and launching the ticker
    String tickerOn = AemDemoUtils.getPropertyValue(buildFile, "demo.ticker");
    if (tickerOn == null || (tickerOn != null && tickerOn.equals("true"))) {
        AemDemoMarquee mp = new AemDemoMarquee(AemDemoConstants.Credits, 60);
        mp.setBounds(140, 440, 650, 30);
        frameMain.getContentPane().add(mp);
        mp.start();
    }

    // Launching the download tracker task
    AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this);
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
    executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS);

    // Loading up the README.md file
    String line = null;
    try {
        FileReader fileReader = new FileReader(
                buildFile.getParentFile().getAbsolutePath() + File.separator + "README.md");
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        while ((line = bufferedReader.readLine()) != null) {
            if (line.indexOf("AEM Demo Machine!") > 0) {
                line = line + " (version: " + aemDemoMachineVersion + ")";
            }
            if (!line.startsWith("Double"))
                System.out.println(line);
        }
        bufferedReader.close();
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }

}

From source file:org.openconcerto.sql.PropsConfiguration.java

public void setupLogging(final String dirName, final boolean redirectToFile) {
    final File logDir;
    synchronized (this.restLock) {
        if (this.logDir != null)
            throw new IllegalStateException("Already set to " + this.logDir);
        logDir = getValidLogDir(dirName);
        this.logDir = logDir;
    }//w w w. java2 s  . c om
    final String logNameBase = this.getAppName() + "_" + getLogDateFormat().format(new Date());

    // must be done before setUpConsoleHandler(), otherwise log output not redirected
    if (redirectToFile) {
        final File logFile = new File(logDir, (logNameBase + ".txt"));
        try {
            FileUtils.mkdir_p(logFile.getParentFile());
            System.out.println("Log file: " + logFile.getAbsolutePath());
            final OutputStream fileOut = new FileOutputStream(logFile, true);
            final OutputStream out, err;
            System.out.println("Java System console:" + System.console());
            boolean launchedFromEclipse = new File(".classpath").exists();
            if (launchedFromEclipse) {
                System.out.println("Launched from eclipse");
            }
            if ((System.console() != null || launchedFromEclipse)
                    && this.keepStandardStreamsWhenRedirectingToFile()) {
                System.out.println("Redirecting standard output to file and console");
                out = new MultipleOutputStream(fileOut, new FileOutputStream(FileDescriptor.out));
                System.out.println("Redirecting error output to file and console");
                err = new MultipleOutputStream(fileOut, new FileOutputStream(FileDescriptor.err));

            } else {
                out = fileOut;
                err = fileOut;
            }
            System.setErr(new PrintStream(new BufferedOutputStream(err, 128), true));
            System.setOut(new PrintStream(new BufferedOutputStream(out, 128), true));
            // Takes about 350ms so run it async
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        FileUtils.ln(logFile, new File(logDir, "last.log"));
                    } catch (final IOException e) {
                        // the link is not important
                        e.printStackTrace();
                    }
                }
            }).start();
        } catch (final Exception e) {
            ExceptionHandler.handle("Redirection des sorties standards impossible", e);
        }
    } else {
        System.out.println("Standard streams not redirected to file");
    }

    // removes default
    LogUtils.rmRootHandlers();
    // add console handler
    LogUtils.setUpConsoleHandler();
    // add file handler (supports concurrent launches, doesn't depend on date)
    try {
        final File logFile = new File(logDir, this.getAppName() + "-%u-age%g.log");
        FileUtils.mkdir_p(logFile.getParentFile());
        System.out.println("Logger logs: " + logFile.getAbsolutePath());
        // 2 files of at most 5M, each new launch append
        // if multiple concurrent launches %u is used
        final FileHandler fh = new FileHandler(logFile.getPath(), 5 * 1024 * 1024, 2, true);
        fh.setFormatter(new SimpleFormatter());
        Logger.getLogger("").addHandler(fh);
    } catch (final Exception e) {
        ExceptionHandler.handle("Enregistrement du Logger dsactiv", e);
    }

    this.setLoggersLevel();
}