禁用glog的“LOG(INFO)”日志 [英] Disable glog's "LOG(INFO)" logging
问题描述
我试图优化我的c ++程序。它使用caffe。
当执行我的程序时,caffe每15分钟输出大约1GB(!)的信息日志。我怀疑这影响效率显着。但我还没有找到如何关闭日志。在此问题中,有人建议您将 FLAGS_v
手动。
I'm trying to optimize my c++ program. It uses caffe.
When executing my program, caffe outputs around 1GB (!) of info logs every 15 mins. I suspect this impacts efficiency significantly. But I haven't found how to turn logging off. In this question someone suggested setting FLAGS_v
manually.
使用以下代码,我可以按级别禁用日志,但<$ c
With the following code I can disable VLOG
logs by level, but LOG(x)
logs are unaffected.
中的第一行main()
:
FLAGS_v = 1; //disables vlog(2), vlog(3), vlog(4)
VLOG(0) << "Verbose 0";
VLOG(1) << "Verbose 1";
VLOG(2) << "Verbose 2";
VLOG(3) << "Verbose 3";
VLOG(4) << "Verbose 4";
LOG(INFO) << "LOG(INFO)";
LOG(WARNING) << "LOG(WARNING)";
LOG(ERROR) << "LOG(ERROR)";
输出:
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0523 19:06:51.484634 14115 main.cpp:381] Verbose 0
I0523 19:06:51.484699 14115 main.cpp:382] Verbose 1
I0523 19:06:51.484705 14115 main.cpp:386] LOG(INFO)
W0523 19:06:51.484710 14115 main.cpp:387] LOG(WARNING)
E0523 19:06:51.484715 14115 main.cpp:388] LOG(ERROR)
code> flag 我不知道?我想要评论每个 LOG(INFO)
行,但我想要一个更优雅的解决方案。 (我想在命令行标志解决方案上的c ++解决方案)。
Is there another flag
I'm unaware of? I'm thinking of commenting every LOG(INFO)
line out, but I would like a more elegant solution. (I'd prefer a c++ solution over a command line flag solution).
推荐答案
您需要设置您的环境变量
you need to set your environment variable
GLOG_minloglevel=2
$ b b
然后运行您的可执行文件。
then run your executable.
您可以找到更多信息这里(在这个页面的底部有一个关于从你的代码中使用宏定义剥离 LOG()
)。
You can find more information here (at the bottom of this page there is a section on stripping LOG()
s from your code using a macro definition).
这篇关于禁用glog的“LOG(INFO)”日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!