Use spring. Net for unified ASP. NET Exception Handling and logging

Source: Internet
Author: User
Tags log4net

Spring. Net is a framework for porting Spring framework to the. NET platform. Compared with other. Net frameworks:

 

  • Not just a DI container-- Although spring. net is often used to compare with other di containers such as castle, but to be precise, spring. net is an application framework, because it has rich APIs and can be used in the entire application, such as data access, web development and integration testing.
  • ASP. NET Framework-- Spring. net ASP. net Framework is not based on ASP. net MVC, the biggest advantage of which is to improve productivity: new users are exploring Di and spring. net often seeks an ASP.. NET Framework.
  • Message-oriented middleware Integration-- Integration with Apache activemq, tibco EMS, and MSMQ simplifies the workload of using these frameworks, which is achieved by extracting low-level thread security issues and using a poco-based programming model.
  • Aspect-oriented programming (AOP)-- Spring. NET provides an extensible AOP framework that includes concepts such as pointcut and advice. It also provides easy-to-use notification implementation, such as logs, abnormal conversions, parameter verification, caching, and automated retries.
  • Ado. netProgramLibrary-- The ADO. Net auxiliary library extracts and simplifies the data source operations of ADO. Net, which reduces a lot of samples.CodeTemplates-based programming models are provided.
  • Expression Language-- Spring. NET provides an expression language that allows you to query and manipulate object graphs at runtime.
  • Integration Test-- Supports integration testing to simplify data access and other operations.
  • Modular-- Distribute features in different DLL files so that developers can select the desired DLL without using the entire framework.
  • Enterprise Support-- Spring. Net was developed by springsource (which was recently acquired by VMware. With the support of large companies, those companies that want to use spring. Net undoubtedly have a reassurance.
  • Code-based container configuration in the plan-- Currently, spring. Net only supports XML-based configuration, while Castle supports XML and "Type ing" APIs. In the next version, spring. NET provides code-based configuration methods similar to spring javaconfig (which has been integrated into spring 3.0.

 

Spring. Net also provides good support for aspect-oriented (AOP), such/* ASP. NET Website Exception Handling and logging */This function can be implemented as follows:

 

 

    • Log errors when exceptions occur in ASP. NET with log4net-- Refer to this article. Log4net is an open-source high-performance logging component. log4net has many advantages, such as recording logs by date, recording logs by directory, and limiting the file size.
    • Use spring. net throw Service-- Implement spring. net spring. AOP. ithrowsadvice interface. When an exception occurs, it calls its own method (for example, calling log4net to record error logs and Sending Short Messages to administrators ), note that the implementation of the ithrowsadvice interface does not mean that this exception has been handled and will continue to be propagated. If you want to abort the application processing process during throw advice processing, you can throw other exceptions. For details, refer to this article.
    • The maximum version of spring. NET is 1.3. It is planned to continue to develop to spring. NET 2.0 in the future. At that time, it will fully support the. net4.0 feature. I believe there will be more functions in the aspect of AOP. For the latest developments in spring. net, refer to infoq.Article: Dialog spring. net

 

Related Article

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.