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

Posted on 2008-11-06
Last Modified: 2008-11-12

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.
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

Question by:gilalig

    Expert Comment

    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.
    LVL 3

    Accepted Solution

    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)

    Author Comment

    Can the streamwriter be used for a file on the web server - not the localhost?


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now