Log file need limit size

来源:互联网 发布:金融信用信息基础数据库查询 编辑:程序博客网 时间:2024/04/29 03:38

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;
0 0