Microsoft Enterprise Library-the beginning of Logging

Source: Internet
Author: User

As msdn introduces logging, almost every enterprise-level application requires a function-log management function, that is, to record certain behaviors of an application, this allows administrators or programmers to understand the behavioral characteristics of programs and improve the "interactivity" between applications ".

The logging Application Block has good configurability and scalability. That is, you can change the configuration to define the log behavior without modifying the code. Of course, you can also extend the log behavior by implementing the interface set provided by the program block. This is in line with the "open-closed" principle followed by software design, especially the program blocks (Libraries) at the bottom of the entire software system. The more dependent, the more you need to follow this principle. The implementation method is basically configuration design. This is also the principle implemented by all program blocks in Microsoft Enterprise Library.

The function of the logging application block is to format the log records generated by the application and record them in various media.

The formatting and media options can be configured by the user.

The core class of the logging Application Block is loggingwriter, which is the log writer. It is packaged by logger and provided to other applications. Logger implements the singleton mode of loggingwriter in the Application Block. After the logentry of the log entity is transferred to loggingwriter, loggingwriter uses filter to filter whether logentry needs to be processed. Of course, the filtering policy is configured by the user (each application has only one policy class ).

After the check, loggingwriter obtains the strategy configured by the user to process the application logs to generate the strategy class (ilogdistributionstrategy). After obtaining the policy class, loggingwriter passes the logentry to the policy class, the policy class continues to process the logentry.

The logging Application Block implements two policy classes: inproclogdistributionstrategy. I translate it into an internal log processing policy. Logdistributor is actually the logdistributor package. logdistributor is the log distributor which calls the user configuration category. Each category has one or more destinations ), each target machine has a logsink and formatter. In this way, logdistributor enumerates each target machine and obtains the logsink in each target machine. The logsink continues to process information. The second is msmqlogdistributionstrategy, which is very special. It bypasses all log processing and directly processes the log in the message queue. This is a strange strategy. Why? In the sink implementation set, msmqsink is already used as the message processing processor for log processing. Why is msmqlogdistributionstrategy required? Still to be studied.

The above is the basic process of the entire logging application block, but there are some additional functions, such as the additional information of the log entity, which is placed in the thread information slot, if you set the information of this information slot, the additional information will be available in the logs of the same thread. In addition, the logging Application Block tracks category-based logs and records them in system logs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.