I have a block of code with logging and I am trying to append a value to each line of log for the entire block, is it possible to append for an entire block of code
Sample code
void MyMethod(){
//code
log
log
//code
log
//code
}
I have a block of code with logging and I am trying to append a value to each line of log for the entire block, is it possible to append for an entire block of code
Sample code
void MyMethod(){
//code
log
log
//code
log
//code
}
Since you only want the timestamps for log entries for this method, you can use a quick private method to acheive your goals:
void MethodToCall(){
logWithTime("Entering Method");
//DoStuff
logWithTime("ExitingMethod");
}
void logWithTime(string logText){
logger.Info(string.format("MethodToCall: {0} {1}", logText, DateTime.Now.ToString());
}