SharePoint Study Notes-Use of debug & troubleshooting-developer dashboard (3. Use it in the assert and critical events Section

Source: Internet
Author: User

If you develop a webpart and present it to a Sharepoint website, Sharepoint creates a top-level scope. In this scope, Sharepoint adds a monitor named spcriticaltracecounter to it, this monitor can be used to insert information to the assert and critical events segments of developer dashborad. For example:


If you click the link on the left of the Information bar, you can get more information about the recorded event (the call stack of the current event ). For example:


How to insert information to the assert and critical events Information Section of developer dashboard? We can use adddatatoscope, a static function of the spcriticalcounter class.

When a request is sent, Sharepoint usually automatically loads the spcriticalcounter monitor. Of course, some other monitors will also be loaded with it. The spcriticalcounter class is defined as follows:

Public Sealed Class Spcriticaltracecounter: ispscopedperformancemonitor, idisposable, isp?cemonitor

Spcriticalcounter is a closed class that inherits the ispscopedperformmonitor interface, which we introduced in the previous article.
We can use the followingCodeTo add user information:

Using (Spmonitoredscope scope = New Spmonitoredscope ( " Customer critical " )){
Spcriticaltracecounter. adddatatoscope (
2010 ,
" Critical error " ,
15 ,
" An critical error occurred " );
}

Adddatatoscope static functions are defined as follows:

Public Static Void Adddatatoscope ( Uint Tagid, String Category, Int Tracelevel, String Message );

In the above definition code
The first parameter is a user-defined tag value (custom tag ID) used to identify record items.
The second parameter is a string type, which is the category of this record item)
The third parameter is an int type, which identifies the trace level. Through reflector analysis, we can see that it corresponds to Microsoft. sharepoint. diagnostics. the enumerated definition of ulstracelevel. The values are as follows:

Internal Enum Ulstracelevel
{
High = 20 ,
Medium = 50 ,
Monitorable = 15 ,
Unexpected = 10 ,
Verbose = 100 ,
Verboseex = 200
}

The fourth parameter is the real record information of this record item.

 

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.