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

前端 未结 13 1213
小蘑菇
小蘑菇 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 20:03

    I would tend to leave them open -- but open them with the file share permissions set to allow other readers and make sure you flush log output with every message.

    I hate programs which don't even let you look at the logfile while they are running, or where the log file isn't flushed and lags behind what is happening.

提交回复
热议问题