I've recently adopted Easylogging++ in my C++ application and have run into what I hope is just something left out of their documentation.
I would like my log file to be cleared each time my application is launched, rather than appending log events from previous application instances. I realize I could just delete the log file on startup prior to any logging events, but this seems like a hack.
Any help would be appreciated. Thanks.
I wasn't able to find a solution to this problem without resorting to editing easylogging++.h. Obviously, I was hoping that wouldn't be necessary but I'm quite certain that as of v9.77, there exists no built-in facility for resetting the log file on application launch. By all means, please correct me if I'm wrong.
Inspecting the code, I found that log files are always created in append mode. There doesn't appear to be any further logic that explicitly deletes log files.
For anyone interested in my hack job, I changed the open mode argument passed into the fstream constructor in utils::File::newFileStream() to include fstream::trunc instead of fstream::app. The change occurs near line 1084 in easylogging++.h, v9.77.
Here's the section of code I'm referring to:
Sorry for the nasty code formatting. I just copied the code the way it is currently formatted in easylogging++.h so that it can be easily recognized.