Skip to content
corwin edited this page Oct 12, 2013 · 6 revisions
  • We use NLog

  • We use Castle dynamic proxies integrated in Autofac container for logging. Each repository, facade and api controller is regitered in Autofac container and logging interceptor is assigned to it. Logging interceptor adds two log entries for each method call - before and after method invocation. All method parameters are flushed to log in JSON format. Return value or exception also is written to log.

  • There is Verbosity notion in logging system. Logable method can be decorated with Log attribute, Verbosity option can be specified. If no verbosity specified - "Default" is assumed (the lowest one). Any field or property of any class can be decorated with the same attribute. When method call is being logged, verbosity is specified too. The rule: method call (object property) is added to log only if verbosity of the method (object property) is less or equal to verbosity of current logger. DAL and BL are logged using "Default" verbosity. API controllers are logged using "Full" verbosity. The main idea - prevent navigation properties of EF entities from being accidentally invoked. Because of that, each navigation property (or collection) must be decorated with "Full" verbosity. Such properties are skipped in DAL. However, they are flushed to log in Web API - since they are sent to the client anyway.

  • Verbosity can be applied to:

    • Method. If logger verbosity isn't appropriate - whole method call will be skipped.
    • Method parameter. If logger verbosity isn't appropriate - parameter value isn't serialized. Special short message is written instead.
    • Method return value. If logger verbosity isn't appropriate - value isn't serialized. Special short message is written instead.
    • Object property/field. When a method parameter or a return value is being serialized, properties/fields with inappropriate verbosity are skipped.
  • Logentries (integrated with NLog) is used for logging in production.

Clone this wiki locally