I want to continuously write lines to a log file. I want to keep adding text to the file and not replacing the stuff i wrote before basically. how can i do it plz help, TIA.
You need to consider how much / how often this occurs. If you are writting a simple / occassional 'note of interest' or the odd err message, it is O.K.
If it is more along the lines of a 'trace log' enumerating each procedure visited, this will generate SOME (several) issues:
[tab]disc activity will dominate the process
[tab]the disc will fill fairly quickly, so you will want to "clear" the contents on occassion (probably each 'start' of the process you are tracing)
[tab]addtional concerns will arise regarding the reading / interpertation of the information recorded, as it can be (?will?) become overwhelming.
ok that works, but i have to open and append the file a LOT of times, i mean this file could log activity over 24 hours maybe more, and i need to constantly write the information to the file, so it could reach a few mb in size. can't this cause it to get corupted? is there no way to keep an open stream and just write to it?
Find some point in the app which 'denotes' the start of the process (could be the StartUp object) open the file. Figure out ALL of the 'ways out' and -in each one-, call the routine to close the file (or just close it).
A reasonable compromise MIGHT be to accumulate the info in a dynamic string array and occssionally open the text file (for APPEND) and write the array contents to the text file, ReDim the text array and start over with the write to the array. This, of course will not work for situations where you are attempting to 'catch' the final agonies of an app which is crashing, but for simple logging it can work reasonably well.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.