Save Terminal Bazel Build Output

Viewed 4055

Is it possible to save the output of a bazel build command that is run in terminal? The command is:

bazel build tensorflow/examples/image_retraining:label_image && 
bazel-bin/tensorflow/examples/image_retraining/label_image 
--graph=/tmp/output_graph.pb 
--labels=/tmp/output_labels.txt 
--output_layer=final_result:0 
--image=$HOME/Desktop/Image-3/image1.png

I want to save the output to a .txt file; I cannot simply tag on > out.txt to the end of the line or I am thrown an error. But is there bazel-output command?

2 Answers

The stdout of the latest bazel command is logged in your WORKSPACE's output base:

$ echo $(bazel info output_base)
/home/username/.cache/bazel/_bazel_username/3e8af127f8b488324cdf41111355ff4c

and the exact file is command_log:

$ echo $(bazel info command_log)
/home/username/.cache/bazel/_bazel_username/3e8af127f8b488324cdf41111355ff4c/command.log

You can do it by piping the output to both text file and command line, but only on linux. You just append this at the end 2>&1 | tee file_name.log

Related