Error Log

G

Guest

I'm trying to put together a function in a VB.NET Class to handle
errors for my ASP.NET application. I want the function to be able to
write to a log file located on the web server. I tried using the
MapPath method but it is not working. It looks like I'm missing some
references in the class.
What do I need to imoprt/reference in my project to be able to
accomplish this?
I tried Imports System.IO, System.Web.HttpContext but none is working
 
J

Jose Rodriguez

Use System.IO with a stream, this example comes from the net help

Imports System
Imports System.IO

Class Test
Public Shared Sub Main()
' Create an instance of StreamWriter to write text to a file.
Using sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write("This is the ")
sw.WriteLine("header for the file.")
sw.WriteLine("-------------------")
' Arbitrary objects can also be written to the file.
sw.Write("The date is: ")
sw.WriteLine(DateTime.Now)
sw.Close()
End Using
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,808
Messages
2,569,685
Members
45,451
Latest member
andrewmcfarland

Latest Threads

Top