I am using Microsoft.Extensions.Logging to output some data and wondering if I could redirect output to a specific file rather than the console. Here is my code:
var loggerFactory = LoggerFactory.Create(loggingBuilder => loggingBuilder
.SetMinimumLevel(LogLevel.Trace).AddConsole());
ILogger logger = loggerFactory.CreateLogger<DataLogger>();
string path = GenerateFilePath();
logger.LogInformation("DataLogger is initialized.");
// todo: redirect output to path.
Is there a way I can redirect my output to the file path?