1. Trang chủ
  2. » Công Nghệ Thông Tin

Exchange SQL And IIS- P181 pptx

5 120 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 203,15 KB

Nội dung

Troubleshooting 101: Diagnostics in IIS 7.0 • Chapter 17 877 Follow the same basic instructions, but this time we’ll add the System.Web assembly from the .NET tab. Ensure that the build is set to Debug by selecting it from the build drop-down menu (see Figure 17.15). Figure 17.15 Setting the Build to Debug using System; using System.Web; using System.Collections; using System.Diagnostics; namespace HowToCheatIIS7 { public class TraceModule : IHttpModule { TraceSource tsStatus; // register callbacks as well as the trace source. public void Init(HttpApplication application) { application.EndRequest += (new EventHandler(this.Application_EndRequest) ); tsStatus = new TraceSource(“tsStatus”); } private void Application_EndRequest(Object source, EventArgs e) { tsStatus.TraceEvent(TraceEventType.Start, 0, “[TraceModule] Start”); tsStatus.TraceEvent(TraceEventType.Warning, 0, “[TraceModule] Warning”); tsStatus.TraceEvent(TraceEventType.Stop, 0, “[TraceModule] Stop”); } public void Dispose() { } } } 878 Chapter 17 • Troubleshooting 101: Diagnostics in IIS 7.0 Compile the application by clicking the Build | Build Solution menu. Once our code has been compiled, we can fi nd the HowToCheatIIS7.dll and HowToCheatIIS7.dll. Add Managed Module to IIS 7.0 With our new module compiled, we’ll now add it to IIS 7.0. Before we can add our new module into IIS, we’ll need to copy our compiled components to the /bin directory of our Web application. Using IIS Manager, we’ll now add our new module into the IIS 7 pipeline. In this example, we’re going to add our module to a specifi c application within the Default Web Site: 1. Click Modules and then click the Open Feature from within the Actions pane. Or you can simply double-click the Modules icon (see Figure 17.16). Figure 17.16 Adding a New Module to IIS 7 2. From the Actions pane, click Add Managed Module…(see Figure 17.17). Troubleshooting 101: Diagnostics in IIS 7.0 • Chapter 17 879 3. In the Add Managed Module window, provide the following information and then click the OK button: ■ Name: HowToCheatIIS7 ■ Type: HowToCheatIIS7.TraceModule This also could be done by directly updating the web.confi g fi le for the application. The following would be added within the <modules> XML node. <add name=“HowToCheatIIS7” type=“HowToCheatIIS7.TraceModule” preCondition=“” /> You’ll now see HowToCheatIIS7 added to the list of modules. Clicking the View Ordered List…link in the Actions pane, you’ll see the actual order in which IIS7 will process each module as a request is submitted to this application. Our new module will be at the bottom of this list. By moving it up in the list, you’ll be able to capture and potentially modify data and actions before later modules. This is extremely useful when you want to trace certain types of information before another module handles the request. Enabling Trace Our module has now been developed, compiled, and confi gured in IIS 7, but we have to tell IIS 7 to listen for tracing information from our new component. The following web.confi g fi le defi nes the three confi guration settings that need to be defi ned for our tracing information within our module to be captured and included in a Failed Request Tracing Log fi le: Figure 17.17 The Add Managed Module 880 Chapter 17 • Troubleshooting 101: Diagnostics in IIS 7.0 <confi guration> <system.webServer> <modules> <add name=“TraceModule” type=“HowToCheatIIS7.TraceModule” /> </modules> </system.webServer> <system.diagnostics> <sharedListeners> <add name=“IisTraceListener” type=“System.Web.IisTraceListener, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” /> </sharedListeners> <switches> <add name=“DefaultSwitch” value=“All” /> </switches> <sources> <source name=“tsStatus” switchName=“DefaultSwitch”> <listeners> <add name=“IisTraceListener” type=“System.Web.IisTraceListener, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” /> </listeners> </source> </sources> </system.diagnostics> </confi guration> Now that all of the pieces are in place, navigate your browser back to the simpletrace.aspx page. Once that page has completed rendering, open the latest FR######.xml fi le using your browser (see Figure 17.18). Any Web developer who is building either a Web application or IIS 7.0 modules can now plug into the Failed Request Trace pipeline. This will result in less time and code the Web developer must focus on creating a tracing mechanism for the application. It will also reduce the number of trace fi les that a Web administrator must use to triage and resolve a given issue relating to a Web application. Although our example explains how to override the tracing mechanism that ships with IIS 7.0, the same type of logic and code could be leveraged within a custom application or another module that is not specifi cally focused on tracing. Take, for example, a developer who is creating a customer authentication module that will replace how IIS 7.0 does authentication. The developer can plug her tracing details within the same tracing pipeline as IIS 7.0. By doing so, the operations team or Web server administrator can get a single trace fi le with all applications participating within a troubled or failed request on a production machine. Troubleshooting 101: Diagnostics in IIS 7.0 • Chapter 17 881 Due to the ability to have a single trace fi le for all components to plug into for a given request, Web server administrators and IT operations managers will be demanding that Web developers and ISVs plug into that infrastructure. In the long term, this will result in faster turnaround in resolving production issues and reduced overhead on server resources. Reality: Inside What Tracing Can’t Do in IIS 7.0 There is one undeniable truth in technology: There is no “magic pixie dust.” The same goes for this powerful feature in IIS 7.0; there are simply some things that it can’t do, and this section exists for this very reason. In some situations, failures exist outside the boundaries of the runtime engine, such as service failures or bad confi gurations. For these cases, most will fi nd the Event Viewer is their best friend, whereas some errors might occur in Web applications during runtime that tracing simply can’t help. In these cases, it is important to understand how to effectively tackle these issues. Figure 17.18 IIS Diagnostics Output and Trace Details . able to capture and potentially modify data and actions before later modules. This is extremely useful when you want to trace certain types of information before another module handles the request. Enabling. components to plug into for a given request, Web server administrators and IT operations managers will be demanding that Web developers and ISVs plug into that infrastructure. In the long term, this. time and code the Web developer must focus on creating a tracing mechanism for the application. It will also reduce the number of trace fi les that a Web administrator must use to triage and

Ngày đăng: 06/07/2014, 15:20

TỪ KHÓA LIÊN QUAN