Skip to main content

Error Log - Error Writer to Text File.

public static void ErrorWriter(string Message, string InnerException, string StackTrace, string FileName, string MethodName)
        {

            try
            {
                string path = "path";
                // This text is added only once to the file.
                // Write to the file:
                if (File.Exists(path) && (new FileInfo(path)).Length > 5 * 1024 * 1024)
                {
                    File.Move(path, path.Replace(".txt", DateTime.Now.Ticks.ToString() + ".txt"));
                }

                string log = string.Empty;
                log += "=============================================================================";
                log += Environment.NewLine.ToString();               
                log += "Data Time:" + DateTime.Now;
                log += Environment.NewLine.ToString();
                log += "Message:" + Message;
                log += Environment.NewLine.ToString();
                log += "InnerException:" + InnerException;
                log += Environment.NewLine.ToString();
                log += "StackTrace:" + StackTrace;
                log += Environment.NewLine.ToString();
                log += "File Name:" + FileName;
                log += Environment.NewLine.ToString();
                log += "Method Name:" + MethodName;
                log += Environment.NewLine.ToString();
                File.AppendAllText(path, log);

            }
            catch (Exception)
            {

            }


        }

Comments

Popular posts from this blog

Postback Page using Javascript in ASP.net

Postback Page using Javascript in ASP.net For Calling Function: __doPostBack('__Page', ''); Function: function __doPostBack(eventTarget, eventArgument) {         if (!theForm.onsubmit || (theForm.onsubmit() != false)) {             theForm.__EVENTTARGET.value = eventTarget;             theForm.__EVENTARGUMENT.value = eventArgument;             theForm.submit();         }     }

Tata Punch: A Compact SUV That Packs a Punch

crystal reports using stored procedures in asp.net

  crystal reports using stored procedures in asp.net   ReportDocument document = new ReportDocument ();         document.Load( this .Page.Server.MapPath( "~/CRY/crTest.rpt" ));         string str = ConfigurationManager .AppSettings[ "ConnectionString" ];         string server = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string database = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));         str = str.Substring(str.IndexOf( ";" ) + 1);         string user = str.Substring(str.IndexOf( "=" ) + 1, str.IndexOf( ";" ) - (str.IndexOf( "=" ) + 1));        ...