Proper way to constantly log to file

I am working on an app that will need a lot of logging. It's a completely offline system and the user wants all the logs to a file.

What is the best way to handle this so that:
  1. All the logs are written in the order that they are called
  2. It won't freeze the app waiting for any of the writing to complete
At first I tried just making every log call a fire and forget task, but I noticed some logs would be out of order.

There can be hundreds of log calls every few seconds so I can't make it synchronous because it freezes the UI (WPF if that matters). Any tips or suggestions would be great.
Was this page helpful?