Blog

How to Generate Log in VB.NET

Posted by Amit Patel Blogs | Visual Basic .NET Nov 13, 2012
This code snippet shows how to add a log file in VB.NET code.
Download Files: LogFiles.rar

Log file generation is very useful in your system to put errors and exceptions in a file. This blog shows how to add a logging feature to a Windows application.

First, you need a copy the Log.Dll file to your project (Download attached file).

Then add reference to Log.Dll by right click on the project, select Add Reference and browse the DLL. 

Now we use Dll in our form.

Declare Namespace.

Imports Log.Log

 After declare namespace you can use writelog function.

You want to print any exception message in log file then use writelog()

WriteLog(ex.ToString(), EventLogEntryType.Error) 

You want to print only message in log file.

WriteLog(“Function Start”)

 

 

PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.