I apply Pitest (PIT) using Maven to Java projects to conduct a mutation analysis. The console's pipe operator only catches Maven-related output but not output by PIT. (This happens both on Linux and Windows.)
How can I redirect the logging output shown on the console to a file?
Maven output are going to stdout
while some PIT logs are going to stderr
. You need to also redirect stderr
to get all logs.
# 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