Walkthrough: Creating a Custom Trace Listener

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 walkthrough demonstrates how to create a custom trace listener for use with the Logging Application Block.

To reproduce the demonstration

  1. Add a new class named DebugTraceListener to your project.
  2. Specify that the class derives from CustomTraceListener.
  3. Add the class attribute ConfigurationElementType. Specify the type CustomTraceListenerData as the attribute parameter.
  4. Add the TraceData method to your class, and then implement the behavior required when logging to your custom trace listener.
  5. Override the Write and WriteLine methods to implement the behavior required when logging to your custom trace listener.
  6. Configure the application to use the Logging Application Block.
  7. In the Enterprise Library configuration tools, configure a new custom trace listener.
  8. Specify DebugTraceListener as the type name.
  9. Create or modify existing categories to use the custom trace listener.