Posts

Showing posts with the label Log Error

Log error in a separate file

You can log your applications errors in separate text file. Use this code public static void WriteException(string msg)         {             try             {                 SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     string LogFile = SPUtility.GetVersionedGenericSetupPath("LOGS",15) + "\\SPErrorLog-" + DateTime.Today.ToString("MM-dd-yyyy") + ".txt";                     StringBuilder sMessage = new StringBuilder();                     msg = msg.Replace("<b>", "");                     msg = msg.Replace("</b>", "");                   ...