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

  • SEARCH
  • Home
  • 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 8828717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:40:17+00:00 2026-06-14T07:40:17+00:00

I am currently in deep need of logging for an existing application, and can’t

  • 0

I am currently in deep need of logging for an existing application, and can’t afford to add the level of logging I expect directly into the code. As a workaround, I’d be happy to have a certain amount of logging done each time an event is fired.

I am considering a solution where I could, at runtime, parse the whole application to wrap all event-to-handler bindings with event-to-wrapper-to-handler; and, ideally, unwrap them at runtime too. In Pseudo-code, this would be:

IDictionary<Event, Action<object, EventArgs>) originalBindings = ...;

public void SetWrapBindings()
{
   var allBindingsToReplace = Assembly.GetAssembly().GETALLEVENTS()
      .Where(eventInfo => eventInfo.GetOtherMethods().Any());

   foreach(var binding in allBindingsToReplace)
   {
     binding.event -= binding.handler;
     binding.event += HandlerWrapper;
     originalBindings.Add(binding.event, binding.handler);
   }

}

public static void HandlerWrapper(object o, EventArgs e)
{
    // Do some logging
    try
    {
       var handler = originalBindings.TryGetValue(/* something */);
       handler.Invoke(o, e);
    }
    // Do more logging
}

In this bunch of pseudo-code there are lots of steps I was not able to write, possibly because I didn’t find the correct API use, but maybe also because some operation in that is theoretically impossible (in which case I’d love to know why). These are:

  • Iterating over all events of the application (this would probably be easy)
  • Identifying a good key for my IDictionary
  • At each step, get the relevant information from the context

Of course, binding one extra handler to each existing event (pre/post-executing a routine without really wrapping the handler) would help, but executing the real handler inside a try-catch is a big nice to have.

Any partial answer is still greatly appreciated

  • 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. Editorial Team
    Editorial Team
    2026-06-14T07:40:18+00:00Added an answer on June 14, 2026 at 7:40 am

    If you’re looking for non-invasive system-wide logging, you’d be better off using an aspect-oriented programming framework like PostSharp. This page provides a decent jumping off point for what you’re looking for.

    Edit: To add to this, look at implementing an EventInterceptionAspect if you really do just want to know when any event is raised. Again, the PostSharp blog is a good source of info, and this article shows an implementation of this aspect that does simple stdout logging of adding, removing, and invoking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to dig deep into python and I have found a challenge
I currently have a three dimensional NSMutableArray which I need to deep copy. However,
I am currently using Serialization in order to make deep copies of some autogenerated
How could I reliably detect, deep in my code, whether the current invocation of
Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
Currently working with converting SQLException error messages into messages that are more useful for
I'm an uber-beginner with Python; I've rather been thrown into the deep end. A
I would like to add licensing system to application. For example: user buys license
We need to generate a TFS repository from a Git source code base, we
I'm currently making an awesome (in my mind) zombie game and I need to

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.