SharePoint [debugging, diagnostics error series]-Use of developer dashboard (3. insert information to assert and critical events segments)

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: ispscoped?cemonitor, idisposable, isp=cemonitor

Spcriticalcounter is a closed class that inherits the ispscopedperformmonitor interface, which we introduced in the previous article.
You can use the following code to 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.