So, I’d like to write a logger in c# for an app I’m working on. However, since I love efficiency, I don’t want to be opening and closing a log file over and over again during execution.
I think I’d like to write all events to RAM and then write to the log file once when the app exits. Would this be a good practice? If so, how should I implement it?
If this is not a good practice, what would be?
(And I’m not using Windows’ event log at this time.)
No. It’s since you love premature optimizations.
If you love efficiency, why do you want to waste a lot of memory for log entries?
It is if you want to lose all logs when your application crashes (since it cannot write the log to disk then). Why did you create the log in the first place?