Configuring Logging Filters

Microsoft Enterprise Library 5.0

DropDown image DropDownHover image Collapse image Expand image CollapseAll image ExpandAll image Copy image CopyHover image

You can filter log entries based on their categories and their priorities. You can also entirely enable or disable logging or add a custom logging filter. The following procedure describes how to configure the logging filters.

To configure logging filters

  1. Select Add Logging Filters as described in Configuration Overview.
  2. If the filter's property pane is not displayed, click the property expander arrow or right-click the filters node you wish to configure.
  3. The Category Filter allows or denies log entries based on their categories:
    • If you want to use a Category Filter, you can select the specific category filter by editing the Categories property. Click the plus sign icon to add a category filter.
    • Type or select the category name for the category that will be filtered. You can either select a name from the drop-down list or type a category name. All Category Filters that have been added to the Category Filters section are available for selection in the drop-down list. The selected category name appears in the lower pane.
    • Repeat to add any other categories you require.
    • To remove a category, click the delete (x) icon beside the category you wish to remove.
    • Repeat to remove any other categories you no longer require.
    • Select a filter mode, either AllowAllExceptDenied or DenyAllExceptDenied.
    • (Optional) Change the name of the category filter. For information about the CategoryFilter properties, see Category Filter Properties.
  4. The Logging Enabled Filter provides a global switch that you can use to turn logging on and off:
    • If you want to log events, set All Logging Enabled to True. To prevent all logging, set All Logging Enabled to False.
    • (Optional) Change the name of the Logging Enabled Filter. For information about the Logging Enabled Filter properties, see Logging Enabled Filter Properties.
  5. The Priority Filter allows or denies log entries based on their priority:
    • (Optional) Set the Maximum Priority property. This is the maximum priority value a log entry can have in order to be logged. If you do not set this property, the value is 2147483647 (this is the largest possible value of a 32-bit signed integer).
    • (Optional) Set the Minimum Priority property. This is the minimum value a log entry must have to be logged. If you do not set this property, the value is -1.
    • (Optional) Change the name of the priority filter. For information about the priority filter properties, see Priority Filter Properties.
  6. A Custom Logging Filter is a class that you have created that derives from the LogFilter class. Its configuration information consists of a collection of name/value string pairs:
    • Set the Type property by clicking the ellipsis button (...) to display the Type Selector. Navigate to and click the filter type name in the Type Selector dialog box. You must select a class that derives from the LogFilter class. It must also have the type CustomLogFilterData specified as the value of the ConfigurationElementType attribute placed on the class.
    • Enter a key/value pair in the Key and Value text boxes. When you enter a key/value pair, a new pair of blank text boxes are displayed.
    • (Optional) Change the name of the Custom Logging Filter. For information about the Custom Logging Filter properties, see Custom Logging Filter Properties.
  7. Repeat the preceding steps for each filter you require.

Category Filter Properties

The following table lists the properties that appear when you add a Category Filter to the Logging Filters section.

Property

Description

Categories

Specifies specific categories that are explicitly allowed, or specific categories that are denied log entries. Use the Category Filter Editor to configure the expression.

Filter Mode

The CategoryFilterMode property that specifies if the filter will allow only messages that match one of the configured categories to pass to the logging target (DenyAllExceptAllowed), or will allow all message except those that match one of the configured categories to pass to the logging target (AllowAllExceptDenied).

Name

The name of the filter. The default is Category Filter.

Logging Enabled Filter Properties

The following table lists the properties that appear when you add a Logging Enabled Filter.

Property

Description

All Logging Enabled

The filter is enabled when this property value is True. The default is False.

Name

The name of the filter. The default is Logging Enabled Filter.

Priority Filter Properties

The following table lists the properties that appear when you add a Priority Filter.

Property

Description

Maximum Priority

The maximum value a log entry can have to be logged. If you do not set this property, there is no maximum value.

Minimum Priority

The minimum value a log entry must have to be logged. If you do not set this property, there is no minimum value. The default is -1.

Name

The name of the filter. The default is Priority Filter.

Custom Logging Filter Properties

The following table lists the properties that appear when you add a Custom Logging Filter.

Property

Description

Attributes

The key/value pairs for this filter.

Name

The name of the filter. The default is Custom Logging Filter.

Type

The type of the trace listener. Select one from the drop-down list. This is required.