Once you've configured the providers you plan on using, you need to decide which events you want to funnel to each provider. You do this using the <eventMappings> and <rules> elements under the <healthMonitoring> section in web.config. Event mappings define groups of events based on a class and/or range of event codes. Remember how every Web event is represented by a class? Since those classes form a hierarchy, it makes it easy to select an entire group of events through a base class. For example, Listing 7-6 illustrates a very useful event mapping defined in the root web.config file. Listing 7-6. A default event mapping
This event mapping matches any Web event that is of (or derives from) the type WebBaseEvent and has an event code between 0 and Int32.MaxValue. In other words, this matches all events, even custom events that you might create for your application. The root web.config file defines several generic event mappings like this that you can use. These don't have any limit on the event code and are matched purely based on type. Table 7-3 lists the names of these default mappings, including the Web event type they match. These predefined mappings may satisfy your needs, but you can add your own more specific groups by including an <eventMappings> section in your web.config file.
Once you have a set of event mappings that's granular enough for what you're doing, you can start funneling those events onto providers using rules. A rule is how you register a provider to listen for a group of events. The order of rules isn't important, and it's completely possible for any given event to be matched by two different rules and therefore sent to two different providers. The root web.config file doesn't include any rules, so if you want any Web events actually recorded, you'll need to add at least one rule to your web.config file. Listing 7-7 is an example of a set of rules that sends all security audits to a security database, while sending all events to a statistical database (these providers were defined earlier in this chapter). Listing 7-7. Defining health monitoring rules in web.config
|