Search code examples
linuxloggingconsoleoutput

How to get Google-glog output in console?


I am using a framework for convolutional neural networks called caffe and its output in console is provided by Google-glog. However when I try to save the output to a file using the following commands:

sh train_imagenet.sh | tee output.txt

or

sh train_imagenet.sh > output.txt

And I get a void file and the output does not save to the file. So I want to know how to retrieve this output. Thanks in advance.


Solution

  • I am using Caffe too. You can try

    sh train_imagenet.sh 2>&1 | tee output.txt
    

    You may also add option -i to tee to ignore Ctrl-C (which passes the SIGINT signal to train_imagenet.sh instead of tee)

    sh train_imagenet.sh 2>&1 | tee -i output.txt
    

    BTW, glog will write log messages to log files by default. The log files provide better severity level seperation than stdout and stderr.

    Unless otherwise specified, glog writes to the filename "/tmp/<program name>.<hostname>.<user name>.log.<severity level>.<date>.<time>.<pid>" (e.g., "/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474").

    By default, glog copies the log messages of severity level ERROR or FATAL to standard error (stderr) in addition to log files.

    Location of the log file can be set by environment variable GLOG_log_dir or by command line flag log_dir (if gflags is installed). See https://godoc.org/github.com/golang/glog for more detail.