title: How to generate the Log File at End of the program Execution
body: <p>I have Developed a console application (using C# and oracle) which will read some data from the Database generate a Excel sheet and send the mail to respective Address.  In my  application I generate a log file and put log in every steps. When my application start running it is creating the Log file and start writing the Log. And my Log file Name is Like:</p>
  
  <pre><code> logFileName = "XYZ"+ "_" + System.DateTime.Today.Date.Day.ToString() + "." + System.DateTime.Today.Date.Month.ToString() + "." + System.DateTime.Today.Date.Year.ToString() + "" + System.DateTime.Now.Hour.ToString()+ ".txt";
  </code></pre>
  
  <p>This file is generate onetime  in a hour and every Execution it is just override the Data. But now I want to generate separate log file for Each Execution of program. If I am trying to add in file name (min,sec) and start writing log file every sec it is generating a new log file  in middle of program execution. So I want to Write Total log in End of the program execution or any error encounter to terminate the program. So where should i store the initial log data and finally i need to write it.</p>
  
  <p>I know there are some relevant post but i did not find the relevant to my concern. Please help me out to find the solution.</p>