0

I am wondering is there a easy way to log all the parameters that where passed into a method, without me having to manually writing it out myself?

public void test(string one, DateTime date, string[] list) {
   logger.debug("Params: {0}, {1},{2}", one, date, list); // instead of having to do something like this, is there something like this
    nlog.logMethod(this) 
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
chobo2
  • 83,322
  • 195
  • 530
  • 832
  • The first thing that came into my mind is AOP(Apect Oriented Programming). Basically you can Inject your on logic(Interceptor) that wrap the method execution. With that you have the complete control before and after the method call. I already used CastleWindsor AOP and Spring.Net AOP modules. – Leonardo Neninger Mar 05 '18 at 17:26
  • 1
    Duplicate of https://stackoverflow.com/questions/2405230/can-i-get-parameter-names-values-procedurally-from-the-currently-executing-funct – Rolf Kristensen Mar 05 '18 at 17:28

0 Answers0