BOOST_LOG_TRIVIAL(严重性)<< ...不重定向到文件 [英] BOOST_LOG_TRIVIAL ( severity ) << ... does not redirect to a file

查看:162
本文介绍了BOOST_LOG_TRIVIAL(严重性)<< ...不重定向到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用的是最简单的boost.log v2版本,其
BOOST_LOG_TRIVIAL(严重性)<< ...

We are using the simplest version of boost.log v2 with BOOST_LOG_TRIVIAL ( severity ) << ...

目前,我们不想创建一个单独的接收器或输出文件,有时将控制台输出重定向到一个文件足以满足我们的目的。在带有boost.log v1.59的CentOs 7中,我们注意到很多时候,当使用各种重定向选项(例如< executable> 2>& 1 out.txt 等。文件结尾为零长度,自然不显示任何屏幕输出。

For the moment we would not like to create a separate sink or output file, sometimes redirecting the console output to a file is good enough for our purposes. Under CentOs 7 with boost.log v1.59 we have noticed that many times the output is not redirected but instead lost completely when using various redirection options like <executable> 2>&1 out.txt etc. The file ends up with zero length and no screen output is present naturally.

有人观察到了这种行为?有已知的解决方法吗?非常感谢,
filimon

Has anybody observed this behaviour? Is there a known fix? Many thanks, filimon

推荐答案

这是对此的解释,无法解决。输出被缓冲,这就是为什么您看不到文件但只能在控制台中看到的原因。只需等待它达到4096字节即可。需要某种刷新缓冲区的方法...

This is explanation of that happens not what could be done. Output is buffered, that's why you can't see anything in file but can see in console. Just wait for it to reach 4096 bytes. Need some way of flushing the buffer...

这篇关于BOOST_LOG_TRIVIAL(严重性)&lt;&lt; ...不重定向到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆