You're manually reinventing the wheel. Use an establish logging framework that handles all of this. Serilog for example has file log sinks and literally has the exact behavior you want for handling logging before being fully setup.