windows c++ fstream log file rollover
-
In my current VS C++ app I create an fstream log file for output and all works fine. It's initialized in the constructor declaration. Now I want to close it and start a new one upon the log file reaching a size limit. I've tried a number of things with no success. One approach was to not initialize in the constructor and use .open. That didn't work. Another was to go back to initialize in the constructor, then close, and rename, and open again. That didn't work either. Either I am missing some key point here or just doing some samll thing incorrectly. Any help would be appreciated. Thanks
-
In my current VS C++ app I create an fstream log file for output and all works fine. It's initialized in the constructor declaration. Now I want to close it and start a new one upon the log file reaching a size limit. I've tried a number of things with no success. One approach was to not initialize in the constructor and use .open. That didn't work. Another was to go back to initialize in the constructor, then close, and rename, and open again. That didn't work either. Either I am missing some key point here or just doing some samll thing incorrectly. Any help would be appreciated. Thanks
Alan Kurlansky wrote:
That didn't work.
This sort of statement is really not very helpful; nobody can guess why it did not work. Explain exactly what you did and what results you got, if there is a short code snippet that helps with the explanation then include that as well. And don't forget to put code between <pre></pre> tags.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Alan Kurlansky wrote:
That didn't work.
This sort of statement is really not very helpful; nobody can guess why it did not work. Explain exactly what you did and what results you got, if there is a short code snippet that helps with the explanation then include that as well. And don't forget to put code between <pre></pre> tags.
Just say 'NO' to evaluated arguments for diadic functions! Ash
Sorry about that. But I was able to get things to work by reducing the scope of the file management. Now I am opening, closing, renaming the file all from within a function, using all local and local static variables.