我一直在寻找一个很好的例子来将进程输出和错误流写入日志文件。我使用apache-commonsexec库来执行我的进程。按照代码示例进行演示publicstaticintexecuteCommand(CommandLinecommand,Loggerlog)throwsExecuteException,IOException{DefaultExecutorexecutor=newDefaultExecutor();executor.setExitValue(0);PumpStreamHandlerpsh=newPumpStreamHandler();executor.setStream