Code: Select all
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.LiterateConsole()
.WriteTo.Async(a => a.RollingFile("logs\\myapp-{Date}.txt",
outputTemplate : "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level} {Type}] {Message}{NewLine}{Exception} {SourceContext}"))
.CreateLogger();
Log.Information("Server starting ...");
//Here I have class which invoke a lot of(6-7) Tasks
NewTask task = new NewTask();
task.Start();
//And I end my Main function with
Log.CloseAndFlush();
Console.ReadLine();
Code: Select all
catch(Exception e)
{
Log.ForContext().Error(e, "Somethign went wrong");
}
BEARBEITEN
Ich habe von hier aus modelliert: https://github.com/serilog/serilog/wiki/Getting-Started
Mobile version