How can I write to a log file?


#1

I would like to either write on the webserver log file or create my own file on the disk. How can I do that?


#2

You can access the file directly using .NET or PHP file commands to create/modify/delete files within your CloudSite file system. Assuming you are using .NET you would use the System.IO classes.


#3

You do it exactly like you would write to your PC’s disk, you only need to use MapPath function

Example (in VB):

let’s say your log file is in a folder named “logs”

filename$=MapPath("~/logs/yourFile.txt")
FileOpen(1,filename, …


If you want to access MapPath from a class, then you need to use System.Web.HttpContext.Current.Server.MapPath