How would I write a log file in c#?
Currently i have a timer with this statement which ticks every 20 secs:
File.WriteAllText(filePath+"log.txt", log);
For everything that i want logged i do this:
log += "stringToBeLogged";
As you can assume the string log just grows and grows as the program runs. (I don't even know if there is a maximum chars per string?)
I assume that there must be better ways of doing this. i just thought that it would be heavy to write the whole file again and again for every time something is added to the log.
Add log to file with Static Class
create a class create a object globally and call this
Refer link:
http://www.codeproject.com/Questions/163337/How-to-write-in-log-Files-in-C
There are 2 easy ways