在测试alljoyn时开启了内部日志,输出太多想重定向到文件中,使用如下命令:

./chat -s aaa >1.txt

居然还是打印到屏幕上而不是输出到文件中。

 

查看alljoyn写日志的代码,发现

void QCC_UseOSLogging(bool useOSLog)
{
    void* context = stderr;
    QCC_DbgMsgCallback cb = QCC_GetOSLogger(useOSLog);
    if (!cb) {
        cb = WriteMsg;
    }
    
    QCC_RegisterOutputCallback(cb, context);
}

原来其日志是输出到stderr而非stdout的,直接使用‘./chat -s aaa >1.txt’ 命令仅重定向stdout,当然达不到效果。

要重定向stderr,使用如下命令即可:

./chat -s zccc &> 1.txt


 

 

 

 

相关文章:

  • 2021-12-03
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
猜你喜欢
  • 2021-05-27
  • 2022-12-23
  • 2021-07-22
  • 2021-11-24
  • 2022-12-23
  • 2021-09-26
相关资源
相似解决方案