I have a problem I have two classes and I want to write both classes into a Serilog file.
class Program
{
static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.WriteTo.RollingFile(logs\\log.txt)
.CreateLogger();
Log.Information("TEST");
}
}
public class data: IData
{
Log.Logger = new LoggerConfiguration()
.WriteTo.RollingFile(logs\\log.txt)
.CreateLogger();
Log.Information("_________________________________________________");
Log.Information("I'm right now in the Class", DateTime.Now);
}
If I were to write this, I would create two log objects and the log information, would be written in different files. So my question is how can I create only one log object that I can use in both classes and that the log information write in only one file.
There is no need to create new log file. This log file is already exists you can append it.