Write Exception Log

Source: Internet
Author: User

 Private voidBtnexception_click (Objectsender, EventArgs e) {            Try            {                Throw NewException ("Anomaly Testing"); }            Catch(Exception ex) {M_writelog (ex); }            finally            {                            }        }        voidM_writelog (Exception ex,stringlogaddress="")        {            //If the log file is empty, the new Yyyy-mm-dd_log.log file is created by default in the Debug directory            if(Logaddress = ="") {logaddress= Environment.currentdirectory +'\\'+ DateTime.Now.Year +'-'+ DateTime.Now.Month +'-'+ DateTime.Now.Day +"_log.log"; }            //output exception information to a fileStreamWriter SW =NewStreamWriter (Logaddress,true); Sw. WriteLine ("Current Time:"+DateTime.Now.ToString ()); Sw. WriteLine ("Exception Information:"+Ex.            Message); Sw. WriteLine ("Exception object:"+Ex.            Source); Sw. WriteLine ("Call stack: \ n"+Ex.            Stacktrace.trim ()); Sw. WriteLine ("Trigger Method:"+Ex.            TargetSite); Sw.            WriteLine (); Sw.        Close (); }

Exception automatically catch the object with exception, the object has the exception information, everything is the idea of the object is worthy of recognition, the exception information pop out of the error box is also a GUI drawing objects drawn out of the dialog box

Mastering the connotation of a technology can be dynamic handwritten code, mastering the various namespaces about what to do, the class under the namespace is concrete implementation, with the constructor event delegate method attributes and other class members to achieve the desired function and

The purpose of the effect.

Write Exception Log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.