我正在使用一个称为caffe的卷积神经网络框架,它在控制台中的输出由
Google-glog提供.但是当我尝试使用以下命令将输出保存到文件时:
sh train_imagenet.sh | tee output.txt
要么
sh train_imagenet.sh > output.txt
我得到一个void文件,输出不保存到文件.所以我想知道如何检索此输出.
提前致谢.
解决方法
我也在使用Caffe.你可以试试
sh train_imagenet.sh 2>&1 | tee output.txt
你也可以在tee中添加选项-i来忽略Ctrl-C(它将SIGINT信号传递给train_imagenet.sh而不是tee)
sh train_imagenet.sh 2>&1 | tee -i output.txt
顺便说一句,glog默认会将日志消息写入日志文件.日志文件提供比stdout和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.
可以通过环境变量GLOG_log_dir或命令行标志log_dir(如果安装了gflags)设置日志文件的位置.有关详细信息,请参见https://godoc.org/github.com/golang/glog.