Issue http://github.com/aspnet/Logging/issues/441 is closed and MS officially recommends to use 3rd party file loggers. You might want to avoid using heavyweight logging frameworks like serilog, nlog etc because they are just excessive in case if all you need is a simple logger that writes to a file and nothing more (without any additional dependencies).
I faced the same situation, and implemented simple (but efficient) file logger: https://github.com/nreco/logging
- can be used in .NET Core 1.x and .NET Core 2.x / 3.x / 4.x / 5.x and .NET 6.0 LTS apps
- supports custom log message handler for writing logs in JSON or CSV
- implements simple ‘rolling file’ feature if max log file size is specified
- Support daily file format log (eg. 2022-03-31.log, 2022-03-30.log)