Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Extending and Modifying the Logging Application Block

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.

In its original state, the Logging Application Block works well for typical logging scenarios. However, there may be times when you need to customize some of the application block's behavior to better suit your application's particular requirements. There are two ways to do this, extension and modification.

  • If you intend to modify or extend the LogEntry class, you may want to use the ReflectedPropertyToken class. This formatting token allows you to log custom properties on custom classes that either derive from the LogEntry class or modify it.This token has the syntax {property(CustomPropertyName)}, and it uses reflection to obtain the value of the specified property and log itto the chosen trace listener. For example, you might have a property named FileName that is the name of the log file. Using this token allows you to insert this name into a log entry.

Extending the Logging Application Block

You extend the application block through designated extension points. Typically, these are custom classes, written by you, that implement a particular interface or derive from an abstract class. Because these custom classes exist in your application space, you do not need to modify or rebuild the application block. Instead, you designate your extensions using configuration settings.

Currently, you can extend the application block by creating new trace listeners, filters, and formatters in addition to those provided with the application block.

For more details, see Extending the Logging Application Block.

Modifying the Logging and Instrumentation Application Block

You modify the application block by making changes to the application block's source code. This may or may not require associated configuration changes. Because changes are made to the source code, you must rebuild the application block before the modifications take effect. You must also be prepared to handle support and versioning issues. To learn more, see Modifying the Logging Application Block.

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.
Show:
© 2014 Microsoft. All rights reserved.