Solved

Create Log Files: ASP.NET VB, SQL 2005

Posted on 2011-09-28
7
238 Views
Last Modified: 2012-05-12
I have created a console application as part of a data integration solution.  In my code, I'm currently writing errors to console.  I would like to create a text log file and write errors to it as well as the application completed time.

how do I create log files in vb.net?

Dim hQry2 As Integer = oAPI.AmQueryCreate(intConn)
                    If (hQry2 = 0) Then
                        Console.WriteLine("hQry2 = 0")  Write to a log file
                    End If
0
Comment
Question by:Annette Wilson, MSIS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 36720357
When you say "log files", are you referring to the Event Log, or just a flat text file?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 125 total points
ID: 36720392
Dim logFile As New System.IO.StreamWriter("yourPath\yourFile.txt", True)
logFile.WriteLine("hQry2 = 0")
logFile.Close()

Open in new window

0
 

Author Comment

by:Annette Wilson, MSIS
ID: 36720554
kaufmed:  Text File

JamesBurger:  Thank you.... I'll try this and get back to you.
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 125 total points
ID: 36772991
You could also do it with one line. It is, of course, a matter of design and preference:
System.IO.File.AppendAllText("C:\path\to\log\file.txt", "hQry2 = 0")

Open in new window

0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36812803
There is cool log4net to write all types of log. You just need to configure and log the error

Check this.
http://www.codeproject.com/KB/aspnet/Log4Net_Configuration.aspx
0
 
LVL 14

Expert Comment

by:binaryevo
ID: 36891697
I use NLog.  No need to re-invent the wheel per say as the dudes at NLog have done a phenomenal job with the library and allow you to do pretty much any type of logging you would want to.  Everything is setup in an NLog.config file.

http://nlog-project.org/
0
 

Author Closing Comment

by:Annette Wilson, MSIS
ID: 37117964
Thank you.  Sorry I took so long to get back to you.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question