In my case I've got a simple listview which contains filepths. When a user double clicks a filepath it does some processing and eventually opens the image. However I need to generate a log file which would output to a text file the date and name of the file executed. What I'm curious to know from you who have had experience with log files is what's an efficient way if generating a log file in this case?

1. Each time the user clicks a listview item i open the log file and write it...possibly on a seperatr thread in the backgrouns.
2. While the app is open, each time a user clicks a list view item I append the log data to an array in memory. Then when the app is closed on the closing event I write to the log file the array of logs.

What do you guys recommend or suggest and why?