Pitest:如何将日志输出重定向到文件?

Pitest: How to redirect the log output to a file?

我使用 Maven 将 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