Log file need limit size

1. Background

Recently, I develop a software, which can log data into a txt file. But finding that this software will crash after long time test about 2 days. After analysing and debugging, find the root reason is that software can’t open the log file immediately under this log rate. Because the log file become very big after long time logging.


2. Limit log file size

When implementing log function, should consider limit the log file size. The flow chart diagram is show as below.
這裏寫圖片描述

Getting file size can use the following code:

CFileStatus fStatus;
long lFileSize;
CFile::GetStatus("FilePath+FileName", fStatus);
lFileSize=fStatus.m_size;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章