Код: Выделить всё
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();
Код: Выделить всё
catch(Exception e)
{
Log.ForContext().Error(e, "Somethign went wrong");
}
РЕДАКТИРОВАНИЕ
Я моделировал отсюда https://github.com/serilog/serilog/wiki/Getting-Started
Подробнее здесь: https://stackoverflow.com/questions/458 ... -is-called
Мобильная версия