Entering Configuration Information

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.

This procedure explains how to configure the Logging Application Block. You will see properties associated with the nodes in the right pane of the Enterprise Library Configuration Console.

To add the Logging Application Block

  1. Open the configuration file. For more information, see Configuring the Application Blocks.
  2. Right-click Application Configuration, point to New, and then click Logging Application Block.

After you add the Logging Application Block to the application configuration, you need to configure some or all of the following elements:

  • Formatters
  • Trace listeners
  • Special trace sources
  • Category sources
  • Filters
  • The application block

The following procedures describe how to configure each element. If you are not going to use one element, you can go on to the next procedure.

The first procedure describes how to configure the formatters. The TextFormatter converts a log entry into a text string. The contents of the string are determined by replacing tokens in the Text Formatter's template property. The BinaryLogFormatter uses the .NET Framework BinaryFormatter to serialize and deserialize the log entry in binary format. The BinaryLogFormatter is required when using the Msmq trace listener with the Message Queuing distributor service.

To configure the formatters

  1. In the Formatters node, right-click Formatters, point to New, and then click the formatter that you want to use.
  2. (Optional) Rename the Name property. The default name is the name of the formatter.
  3. If you are adding the Text Formatter and want to change the template that controls how the text looks, click <template>. Click the ellipsis button (…). The Template Editor appears. Make the changes you want. You can use the InsertToken button to add tokens with the appropriate syntax. After you finish making the changes you want, click OK.
  4. If you are adding a CustomFormatter and want to edit the key/value pairs, click the ellipsis button (…) and use the EditableKeyValueCollectionEditor. This editor allows you to specify configuration information for the CustomFormatter. This configuration information is a collection of key/value string pairs.
  5. Repeat the procedure for each formatter you want to use.
Ff647805.note(en-us,PandP.10).gif
Note: The timestamp token supports a local: prefix that indicates that the timestamp should be displayed in local time. Some examples of local timestamp format codes include {timestamp(local)}, which uses the default format stringand {timestamp(local:F)}, which uses the F format string that represents the “full date/time” pattern. For more information about date/time formatting, see Standard DateTime Format Strings on MSDN.

The following procedure describes how to configure the trace listeners. Trace listeners receive log entries and write them to the appropriate destinations. There is a specific procedure for configuring a custom trace listener, which is the "To configure a custom trace listener" procedure. There is also a specific procedure for configuring the two trace listeners that are required for integration with WCF. This is the "To configure the WCF-integration trace listeners" procedure in Integrating the Logging Application Block with WCF Applications.

To configure the trace listeners

  1. In the TraceListeners node, right-click TraceListeners, point to New, and then click the trace listener that you want to use. Each trace listener has a set of properties associated with it. For information about these properties, see Logging Application Block Properties.
  2. If you are going to use the distributor service, you must select the MsmqTraceListener option. For information about how to use the distributor service, see Using the Distributor Service.
  3. Set the Formatter property by clicking the formatter you want to use (if any) in the drop-down list. If you are configuring the MsmqTraceListener to use it with the Message Queuing distributor service, you must select the BinaryFormatter.
  4. If necessary, change the values of other properties. To do this, either type a new value or select an option in the drop-down list.
  5. Repeat the procedure for each trace listener you add.

Note

When you add a System.Diagnostics trace Listener and set the Type attribute, the Type Selector displays trace listener types that derive from the System.Diagnostics.TraceListener class. This means that the Type Selector displays the trace listener types that are a part of the EnterpriseLibrary.Logging.TraceListeners assembly as well as the trace listener types that are a part of the System.Diagnostics assembly. Only select types that belong to the System.Diagnostics assembly. It is possible to use some of the Enterprise Library trace listeners but only those that require either no parameters or one parameter, which is the same as the System.Diagnostics trace listeners. These trace listeners are the Formatted EventLog TraceListener, the Flat File TraceListener, and the WMI TraceListener.

To configure a custom trace listener

  1. In the TraceListeners node, right-click TraceListeners, point to New, and then click CustomTraceListener.
  2. If you need to set attributes, go to the Attributes property section of the right pane and click the ellipsis button (...).
  3. In the EditableKeyValueCollectionEditor dialog box, enter the key name and the value of the property.
  4. Add more name/value pairs as appropriate, and then click OK.
  5. (Optional) Set the Formatter property by clicking the formatter you want to use in the drop-down list. The default is none.
  6. (Optional) Rename the Name property. The default name is Custom Trace Listeners.
  7. (Optional) Set the TraceOutputOptions property by clicking the value you want to use in the drop-down list. For an explanation of the values, see TraceOutput Options Values in Entering Configuration Information. The default is None.
  8. In the Type property section, click the ellipsis button (…). If the type you want is not included in the Assemblies folder, click Load Assembly on the Type Selector to find the assembly that contains the type you want.
Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The latest Enterprise Library information can be found at the Enterprise Library site.