Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 45337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:47:35+00:00 2026-05-10T15:47:35+00:00

I am considering using Postsharp framework to ease the burden of application method logging.

  • 0

I am considering using Postsharp framework to ease the burden of application method logging. It basically allows me to adorn methods with logging attribute and at compile time injects the logging code needed into the il. I like this solution as it keeps the noise out of the deign time code environment. Any thoughts, experiences or better alternatives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:47:36+00:00Added an answer on May 10, 2026 at 3:47 pm

    I apply logging with AOP using Castle Windsor DynamicProxies. I was already using Castle for it’s IoC container, so using it for AOP was the path of least resistence for me. If you want more info let me know, I’m in the process of tidying the code up for releasing it as a blog post

    Edit

    Ok, here’s the basic Intercepter code, faily basic but it does everything I need. There are two intercepters, one logs everyhing and the other allows you to define method names to allow for more fine grained logging. This solution is faily dependant on Castle Windsor

    Abstract Base class

    namespace Tools.CastleWindsor.Interceptors { using System; using System.Text; using Castle.Core.Interceptor; using Castle.Core.Logging;  public abstract class AbstractLoggingInterceptor : IInterceptor {     protected readonly ILoggerFactory logFactory;      protected AbstractLoggingInterceptor(ILoggerFactory logFactory)     {         this.logFactory = logFactory;     }      public virtual void Intercept(IInvocation invocation)     {         ILogger logger = logFactory.Create(invocation.TargetType);          try         {             StringBuilder sb = null;              if (logger.IsDebugEnabled)             {                 sb = new StringBuilder(invocation.TargetType.FullName).AppendFormat('.{0}(', invocation.Method);                  for (int i = 0; i < invocation.Arguments.Length; i++)                 {                     if (i > 0)                         sb.Append(', ');                      sb.Append(invocation.Arguments[i]);                 }                  sb.Append(')');                  logger.Debug(sb.ToString());             }              invocation.Proceed();              if (logger.IsDebugEnabled && invocation.ReturnValue != null)             {                 logger.Debug('Result of ' + sb + ' is: ' + invocation.ReturnValue);             }         }         catch (Exception e)         {             logger.Error(string.Empty, e);             throw;         }     } } } 

    Full Logging Implemnetation

    namespace Tools.CastleWindsor.Interceptors { using Castle.Core.Logging;  public class LoggingInterceptor : AbstractLoggingInterceptor {     public LoggingInterceptor(ILoggerFactory logFactory) : base(logFactory)     {     } } } 

    Method logging

    namespace Tools.CastleWindsor.Interceptors { using Castle.Core.Interceptor; using Castle.Core.Logging; using System.Linq;  public class MethodLoggingInterceptor : AbstractLoggingInterceptor {     private readonly string[] methodNames;      public MethodLoggingInterceptor(string[] methodNames, ILoggerFactory logFactory) : base(logFactory)     {         this.methodNames = methodNames;     }      public override void Intercept(IInvocation invocation)     {         if ( methodNames.Contains(invocation.Method.Name) )             base.Intercept(invocation);     } } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 223k
  • Answers 223k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'd say ftplugin, it's very easy. Write this in .vim/ftplugin/objc.vim:… May 13, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer What happens if you specify an index hint? Try this:… May 13, 2026 at 12:30 am
  • Editorial Team
    Editorial Team added an answer It's not protected, I guess you lost the execution right… May 13, 2026 at 12:30 am

Related Questions

I am considering using Maven for a Java open source project I manage. In
I am considering using a Shared (read static) WCF proxy client for a high
I am considering using SCTP instead of TCP for a p2p app written in
I am considering using ADO.Net Data Services in a project for the purpose of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.