简体   繁体   English

将Google日志(glog)重定向到文件

[英]Redirect Google log (glog) to file

I have a small console application which uses a library (statically linked) that uses glog to cout or cerr for printing the log messages. 我有一个小型控制台应用程序,它使用一个库(静态链接),该库使用glog提示或cerr打印日志消息。 I want to redirect these messages to file, but using the method specified here doesn't work (Tried it for both cout and cerr). 我想将这些消息重定向到文件,但是使用此处指定的方法不起作用(对cout和cerr都进行了尝试)。

This is a 3rd party library and I don't have their code, but know for sure that this library uses glog for logging. 这是一个3rd party库,我没有他们的代码,但是可以确定该库使用glog进行日志记录。

How can I still redirect it to a file? 我如何仍将其重定向到文件?

Much thanks! 非常感谢!

Well, after adding the log initiating line: 好了,在添加日志启动行之后:

::google::InitGoogleLogging(argv[0]);

and then redirect the streams like suggested here , this worked. 然后像这里建议的那样重定向流,这可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM