Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 545
  • Last Modified:

Create a log file for a web server from a web service

Hello,

I need to write to a file in order to log values received through a web service in ASP.NET/VB.Net. This file must be on the web server . What code can I write for this in the web service ?

Attached is what I have written but I'm not sure if it is good for a web server or only when working with localhost.
Thanks
strWriteLog = "LogDateTime:" & Date.Now.ToString & " Key:" & sKey & " UpdateDate:" & Rec.UpdateDate 
 My.Computer.FileSystem.WriteAllText("C:\inetpub\wwwroot\site\myDir\Files\traceDates.txt", strWriteLog, True)

Open in new window

0
gilalig
Asked:
gilalig
1 Solution
 
kevink34Commented:
Would it work to write an entry to the event log?
Diagnostics.EventLog.WriteEntry(AppName, "Key:" & sKey & " UpdateDate:" & Rec.UpdateDate)

It will track your times, etc.

Just a thought.
0
 
Mike_VCommented:
Stream Writer?

Dim MyLogFile as String
MyLogFile = "C:\inetpub\wwwroot\site\myDir\Files\traceDates.txt"
Dim sw As StreamWriter
sw = New StreamWriter(MyLogFile, True)
sw.WriteLine("LogDateTime:" & Date.Now.ToString & " Key:" & sKey & " UpdateDate:" & Rec.UpdateDate)
sw.Close()
0
 
gilaligAuthor Commented:
Can the streamwriter be used for a file on the web server - not the localhost?

Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now