Shaitan00 Posted August 30, 2005 Posted August 30, 2005 I created a LOG file (ErrorLog) that I use to output/trace information from my application, problem is the I want to be able to read the file as things progress. Given the way I coded it (see below) the information I write into the file is only saved afer I do the .CLOSE (meaning that if I open the .log file there is nothing written until I do the .close) I would much rather be able to read the .log file while the application is running to see if anything is generated... (I don't want to have to CLOSE the file to see what was written to it). StreamWriter ErrorLog = new StreamWriter(File.Open("App.log", FileMode.Append, FileAccess.Write, FileShare.ReadWrite)); string errMessage = DateTime.Now + ": " + sMessage; ErrorLog.WriteLine(errMessage); ... ... do some work ... ... ErrorLog.Close(); [/Code] Any helps/hints/clues would be appreciated - I know there is a way I just can't recall how to get it to work. Thanks, Quote
Joe Mamma Posted August 30, 2005 Posted August 30, 2005 why not use .Net eventlog class Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
Shaitan00 Posted August 30, 2005 Author Posted August 30, 2005 Had trouble getting it to work and decided it would be best to just write one from scratch I could just package in a personal library or something... Quote
Administrators PlausiblyDamp Posted August 30, 2005 Administrators Posted August 30, 2005 Personally I would agree with Joe Mamma on this and would use the built in eventlog support - much better for administrators as your app will log to the same place as all other applications, plus there are standard tools for viewing, searching etc. Failing that have you tried calling .Flush() and seeing if that makes a difference? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.