I have been searching for a while to get a good example for writing Process output & error stream to log file. I use apache-commons exec library to execute my process. Following a code sample to demonstrate that

public static int executeCommand(CommandLine command, Logger log) throws ExecuteException, IOException {
    DefaultExecutor executor = new DefaultExecutor();
    executor.setExitValue(0);

    PumpStreamHandler psh = new PumpStreamHandler();
    executor.setStreamHandler(psh);

    return executor.execute(command);
}
Edit
Report