我使用Maite将Pitest(PIT)应用于Java项目以进行突变分析。控制台的管道操作员仅捕获与Maven相关的输出,但不通过PIT输出。 (这在Linux和Windows上都会发生。)
如何将控制台上显示的日志输出重定向到文件?
Maven输出将转向stdout
,而一些PIT日志将转向stderr
。您还需要重定向stderr
以获取所有日志。
# this will write both outputs to a file
mvn clean install &> both-outputs.log
# this will also write both outputs to a file
mvn clean install > both-outputs.log 2>&1
# to pipe both outputs you need to do this
mvn clean install 2>&1 | any-command-reading-from-stdin