I have to log activity of application that runs in many threads. What would be best approach to do that? Probably it is not possible that all threads log into one file, because they will lock each other? Is it best to use separate file for each thread then?
I use this within a method that is called by threads at the moment:
f=File.open(...)
f.puts "log message"
f.close
All threads are calling this method. I will append thread number to file name so that every thread creates its own file. This method is called when thread calls it and gives it new information to log. Then method opens file, writes information and closes it again. However is this opening and closing of file time-consuming in time-critical application? Or is this not something to be concerned of?