Apr 24, 2008

How to write Text / Trace / Log file using ASP?

How to write Trace file using ASP?

Previously I wrote for how to write text file with ASP , Now one step forward how to write trace file with ASP?

So here we goes.

Create a text file .

1. Create an File system object that is used for File Access

2. Get the File Path

3. Create the file if not exist.

4. Open the File

5. Log the Server Variables

6. Close the File object release all memory

set FSO = Server.CreateObject("scripting.FileSystemObject")

Dim filePath

filePath = Server.MapPath("Trace.txt");

set myFile = fso.CreateTextFile(filePath ,8, true) 'Here 8 means we using for appending

myFile.WriteLine(Request.servervariables("SERVER_NAME"))

myFile.WriteLine(Request.servervariables("SCRIPT_NAME"))

myFile.WriteLine("Write more looging tuff")

myFile.Close

2 comments:

  1. or just use Trace.Write("message") with tracing enabled andf configured in web config

    ReplyDelete
  2. I dont think there is a web config available for asp. Also Trace.Write works for ASP.NET.

    ReplyDelete

SQL - Difference between CAST,CONVERT and PARSE

TODO---