Поделиться через


The Logging Application Block

Developers frequently write applications that require logging functionality. Typically, these applications format and log information in response to application events. For example, they may be required to log information in response to unexpected conditions, such as an application exception, or failure to connect to a database. Developers also write code to trace application flow through components during the execution of an application use case or scenario. In addition, applications often need to write information locally and over a network. In some cases, you may need to collate events from multiple sources into a single location.

The Enterprise Library Logging Application Block simplifies the implementation of common logging functions. You can use the Logging Application Block to write information to a variety of locations:

  • The event log
  • An e-mail message
  • A database
  • A message queue
  • A text file
  • A Windows® Management Instrumentation (WMI) event
  • Custom locations using application block extension points

This section includes the following topics that will help you to understand and use the Logging Application Block:

  • What Does the Logging Block Do? This topic provides a brief overview that will help you to understand what the block can do, and explains some of the concepts and features it incorporates. It also provides a simple example of how to write code to use the block.
  • When Should I Use the Logging Block? This topic will help you to decide if the block is suitable for your requirements. It explains the benefits of using the block, and any alternative techniques you may consider. It also provides details of any limitations of the block that may affect your decision to use it.
  • Developing Applications Using the Logging Application Block. This topic explains how to use the Logging Application Block in your applications. It shows how to configure the application block to perform common tasks and how to add application code to the application block where required.
  • Key Scenarios. This topic demonstrates how to use the application block to perform the most common logging operations.
  • Design of the Logging Application Block. This topic explains the decisions that went into designing the application block and the rationale behind those decisions.
  • Extending and Modifying the Logging Application Block. This topic explains how to extend the application block by creating your own custom trace listeners, log formatters, and log filters; and explains how to modify the source code.
  • Deployment and Operations. This topic explains how to deploy and update the application block's assemblies and also contains information about the instrumentation in the block.

More Information

For more information about logging and managing other crosscutting concerns, see the following patterns & practices guides: