0

How to create attribute based logger class which would read the all the input paramters of method and response object of method and both log into database.

so,

 [LogReqResponse(request:fieldname,LogObject:Employee,Message:"")]
 public int GetData(string id,Employee e)
{
...
return resultId;
}

so, LogReqResponse's class would have - ID, Employee object where, I do related processing and log into database and , response of method also log into database.

How can I achieve this.

there is no action filter kind of thing, its just C# class library 4.6.2 framework. ///////////////// this is different that mentioned question.

Updated code above, method should process as per specified file for request,logobject and message and log into database after processing.

How to create such logger class that read method's paramter as well give response of method also to log. its all in attribute class.

user3711357
  • 1,425
  • 7
  • 32
  • 54
  • An AOP (Apect Oriented Programming) framework like [PostSharp](https://www.postsharp.net/) can help. Or [Fody](https://github.com/Fody/Fody). There are more, google AOP and C# might give some more information – Peter Bons Jul 27 '17 at 17:54
  • its paid actually. looking free solution that can implement. – user3711357 Jul 27 '17 at 17:56
  • You need an AOP framework or you will incur a massive performance penalty, or simply write the code into the method manually. There is no magical bullet here. – Lasse V. Karlsen Jul 27 '17 at 18:32
  • can you please share me any example link or stuff for attribute class method. that attribute will apply across the multiple classes's methods. – user3711357 Jul 27 '17 at 18:59

0 Answers0