Git Product home page Git Product logo

logging-interception-demo's Introduction

For information on other topics of interest, see my blog at:

http://codingsolutions.blogspot.com/

David Gadd

*****

This sample code demonstrates how to use a combination of Castle's IOC container (using explicit component config settings) with log4net and Castle's IInterceptor interface
to log the interactions between interfaces.

KEY POINTS TO OBSERVE:
1) In the unit tests project, the test with mocks demonstrates the proposed service method interaction, using 3 interfaces
2) In the integration tests project, fake implementations have been provided for each interface. These are the implementations that will be logged by Castle's IInterceptor.
3) In the app.config file for the integration test project, each interface has been mapped to the implementation through <castle> component entries.
4) In the app.config, each component entry has a nested reference to the LoggingInterceptor class, a custom class which implements IInterceptor.
5) The LoggingInterceptor class also contains a LogNow() method, which calls to log4net to perform the actual logging.
6) Default log4net settings have been included in the app.config file in the integration test project; note that it is currently set to write to C:\LogFiles\ directory.
7) The interfaces interact with domain entities from the Domain namespace. If the ToString() method of these domain entities were not overwritten, then the logging information
for the parameters and return types of the interface methods would be fairly dull.
8) To prevent this, the domain entities inherit from a base class, PrimaryKeyBase. This class kind of violates SRP, because it actually now does two things:
   a) It declares an Id property. (This can be useful for domain/ORM identity/equality).
   b) It provides a ToString() implementation which writes out all of the class properties using reflection.
9) This second purpose of ToString() overriding results in detailed information on the domain entity property values when writing to the Log from LoggingInterceptor.

logging-interception-demo's People

Watchers

olcay seker avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.