Link to home
Start Free TrialLog in
Avatar of Chizl
ChizlFlag for United States of America

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chizl

ASKER

Thought of that, but unfortunatly, thats going to make it 2 logs with the max size, I only want 1.
>> 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 ?
Avatar of Chizl

ASKER

Client specification
>>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.
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 ?
Avatar of Chizl

ASKER

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.