Using system; using system. collections. generic; using system. web; using system. io; using system. text; /// <summary> /// summary description for netlog // </Summary> public class netlog {// <summary> /// write the log to a text file // /</Summary> /// <Param name = "action"> action </param> /// <Param name = "strmessage"> log content </param> // /<Param name = "time"> time </param> Public static void writetextlog (string action, string strmessage, d Atetime time) {string Path = appdomain. currentdomain. basedirectory + @ "SYSTEM \ log \"; if (! Directory. exists (PATH) directory. createdirectory (PATH); string filefullpath = path + time. tostring ("yyyy-mm-dd") + ".system.txt"; stringbuilder STR = new stringbuilder (); Str. append ("time:" + time. tostring () + "\ r \ n"); Str. append ("Action:" + Action + "\ r \ n"); Str. append ("message:" + strmessage + "\ r \ n"); Str. append ("----------------------------------------------------------- \ r \ n"); streamwr Iter sw; If (! File. exists (filefullpath) {Sw = file. createtext (filefullpath);} else {Sw = file. appendtext (filefullpath);} SW. writeline (Str. tostring (); Sw. close ();}}