Should log file streams be opened/closed on each write or kept open during a desktop application's lifetime?

前端 未结 13 1182
小蘑菇
小蘑菇 2020-12-04 19:52

Should log classes open/close a log file stream on each write to the log file or should it keep the log file stream open throughout the application\'s lifetime until all log

13条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 19:57

    For performance, keep open. For safety, flush often.

    This will mean that the run-time library will not try to buffer writes until it has lots of data -- you may crash before that's written!

提交回复
热议问题