Currently , I am capturing execution time of each API using log4net and explicitly mentioning the start time and end time at the beginning and end of each API and writing into log file, as below
[HttpGet]
Public IHttpActionResult GetProducts()
{
Log.info("API Execution Started at " + DateTime.Now());
Var Products = UnitOfWork.GenericRepo.GetProducts();
Log.Info("API Execution Completed at "+ DateTime.Now());
Return Ok(Products);
}
Is there a better way to capture the execution time of each API and write that into a log file ? Also, Please provide me an insight on how to capture Tracing information of all APIs and writing that into different log files. For Example , Execution time of each API should be written into "ExecutionLog.txt" and Tracing infomration into "TracingLog.txt". I should also be able to enable or disable this features during run time.
Thanks in advance