C # custom logging,
If you don't talk much about it, go directly to the Code:
Simple: copy the class to the project, and configure logUrl in the configuration file. Saved in: Project/temp/log by default
/// <Summary> /// log class /// </summary> /// <remarks> Creator: v-lxh CreateTime: 11:18:09 </remarks> // <Description> </Description> public class Log {// <summary> // write the Log. /// </summary> /// <param name = "strList"> The STR list. </param> // <remarks> Creator: v-lxh CreateTime: 2016/7/26 11:18:09 </remarks> // <Description> </Description> public static void WriteLog (params object [] strList ){/ // Determine whether the log mode is enabled // if (! LogModel) return; if (strList. count () = 0) return; // log file path string strDicPath = ""; try {strDicPath = HttpContext. current. server. mapPath ("~ /Temp/log/"); if (strDicPath = null | strDicPath =" ") {strDicPath = System. configuration. configurationManager. deleetask[ "logUrl"] + "/temp/log/" ;}} catch (Exception e) {strDicPath = System. configuration. configurationManager. appSettings ["logUrl"] + "/temp/log/";} string strPath = strDicPath + string. format ("{0: yyyy-MM-dd}", DateTime. now) + "log .txt"; if (! Directory. Exists (strDicPath) {Directory. CreateDirectory (strDicPath);} if (! File. exists (strPath) {using (FileStream fs = File. create (strPath) {}} string str = File. readAllText (strPath); StringBuilder sb = new StringBuilder (); foreach (var item in strList) {sb. append ("\ r \ n" + DateTime. now. toString () + "-----" + item + "");} File. writeAllText (strPath, sb. toString () + "\ r \ n ----- z ----- \ r \ n" + str );}}