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

gilaligAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gilaligAuthor Commented:
Can the streamwriter be used for a file on the web server - not the localhost?

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.