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”)

 

 

COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter