classic asp log

ITsolutionWizard
ITsolutionWizard used Ask the Experts™
on
Hi ! I would like to get some log on text file.
Like on my classic asp page when a button is click, I want to record some thing like
"Quote is created on 01/01/2017 12:23" and the file directory is: C:\QA Logs\log.txt
And I want to accumulate so I can check all the records.

How can I do that in classic asp?

I have no idea how it work in classic asp. so simple better :-)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Big MontyWeb Ninja at large

Commented:
Here's a pretty straight forward example on how to create a log file. You can change it around to save whatever info you want, but it should at least get you started. If you have any specific questions feel free to ask.

http://www.devasp.com/samples/logfile.asp
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Make sure you give write permissions to C:\QA Logs\ for your web user or you will get a permissions error.  The code below assumes you already have a file named, C:\QA Logs\log.txt and is modified from  http://www.4guysfromrolla.com/webtech/faq/FileSystemObject/faq3.shtml

<%
' Append a log file to C:\QA Logs\log.txt 
' "Quote is created on 01/01/2017 12:23"
' http://www.4guysfromrolla.com/webtech/faq/FileSystemObject/faq3.shtml

Const fsoForAppend = 8

Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("C:\QA Logs\log.txt", fsoForAppend)

'Display the contents of the text file
objTextStream.WriteLine "Quote is created on "&now


'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing

%>

Open in new window

I suggest making this an include file and that way you can insert the include file anywhere you need it and if you ever need to make a change, you change only one file.

You can add it to a page where you accept the form data directly or if you are  using ajax, include it in your ajax page.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial