Solved

Create Log Files: ASP.NET VB, SQL 2005

Posted on 2011-09-28
7
228 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
7 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
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
Comment Utility
kaufmed:  Text File

JamesBurger:  Thank you.... I'll try this and get back to you.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you.  Sorry I took so long to get back to you.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now