开发者

Keeping 'almost complete' logs even when system crashes

We have a c++ application (console) that runs on windows and unix. This application used output files to output verbose log files of system calls/prints/etc. The prblem is, that in certain occasion we might get signal 11/2 after new features are added.

Now whenever, that happenes, we do not get 'almost complete' information from log files to track down the origin of the bug/problem since the output files are no开发者_JAVA技巧t closed properly when signal 11 occurs. (it's only partial or zero sized)

We considered adding a flush command after every fprintf line print. Q :

  1. Is that considered a good practive ?
  2. does fflush works well on windows platfrom ?
  3. any thoughts/other methods to keep log files while system might crash unexpectedly ?


You need to send the log data not to the file, but to some external logging application which you can create in 30 minutes. Sending of output is possible via socket or via pipes or using SendMessage() Windows API ( if you target Windows ).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜