• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Max Log Size

VC++ 6, ATL, STL, Non-MFC

My application writes logs and now I want to setup a max log size that is configurable by the user.   I'm trying to come up with the best way of doing that without having to load up the full log into memory, which could be 2MB, then starting from the end, delete data off the top.    Is there a better way or does someone have a function that already does this?
0
Chizl
Asked:
Chizl
  • 3
  • 2
  • 2
1 Solution
 
AxterCommented:
Check out the logging library, in the following link:
http://axter.com/ezlogger/

The method I use, is to have two log files.  When the primary log file reaches the maximum length, I delete the old version, and rename the current log file.
Then create a new log file with the standard name.

if (maxsize)
{
  //Close file
  //Rename file to log.old
  //Create new file with standard name
}
0
 
ChizlAuthor Commented:
Thought of that, but unfortunatly, thats going to make it 2 logs with the max size, I only want 1.
0
 
Infinity08Commented:
>> Thought of that, but unfortunatly, thats going to make it 2 logs with the max size, I only want 1.

Then make 2 logs of half the max. log size ;)

The solution using two log files is a lot easier than removing from the file, and adding to it. Is there a specific reason that you only want one file ?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ChizlAuthor Commented:
Client specification
0
 
AxterCommented:
>>Client specification
Many times client specifications do not lead to what is best for the client, and it's up to the developer to clarify that with the client, so that they can make an inform decision on their specifications.

The two log method is the cleanest most efficient method I found to do this.
There are other methods, that would put an impact on performance, which i would not recommend.
0
 
Infinity08Commented:
Well, another easy "solution" is to just erase the log file once it reaches a certain size, and start over. Although you will have periods with no or little logs ... Is that a problem ?
0
 
ChizlAuthor Commented:
Erasing is a problem..   I'm going to go with the multiple logs..   2MB max, then 1MB archive, with a 1MB working log..    They wanted the 1 file and I figured there was an good way to do that, but guess not.  

Thanks for everyone's help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now