Log File
-
How can i implement a log file which record my application activity.
-
How can i implement a log file which record my application activity.
I'm not sure if there's any automatic way, but I use a class of static logging methods and a lazy initialised file stream which is closed in IDispose. Christian Graus - Microsoft MVP - C++
-
How can i implement a log file which record my application activity.
If you want to write to an O/S filesystem (text) file - see help on file streams and text files (I assume you do not need this). See System.IO namespace. To log to the windows event log (I assume this is what you want something like this): Private Shared Sub WriteToAppLog( _ ByVal message As String _ , ByVal messageType As EventLogEntryType _ ) Dim elLog As System.Diagnostics.EventLog Try elLog = New System.Diagnostics.EventLog( _ "Application" _ , Environment.MachineName _ , Application.ProductName _ ) elLog.WriteEntry(message, messageType) Catch ex As Exception 'Your error handling here End Try End Sub I suggest you write a reusable application-message class handling messages to user/screen, text log file or Windows Event log (or any combination there in). Use designation before your enum declaration to "OR" these options together in a bitwise fashion. Good luck, -Len Thanks, -Len Miller "If I had eight hours to chop down a tree, I'd spend six sharpening my axe." -Abraham Lincoln
-
How can i implement a log file which record my application activity.
A basic implementation for this is already provided in the framework. The TraceListener class might be a good start for reading. If you need something more sophisticated you should have a look at NLog. This article describes the basics for using it.