【发布时间】:2018-02-03 03:56:32
【问题描述】:
我有 5 个 .net-core 项目的解决方案,一个控制台应用程序和其余的是类库。在主函数的类程序中,我有:
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<ClassName>().Error(e, "Somethign went wrong");
}
在新日志中,我只有“服务器正在启动...”,仅此而已。我应该做什么?当我调试时,我看到我的程序使用catch 运行。现在我不知道该怎么办。也许有人有类似的问题?
编辑 我从这里建模https://github.com/serilog/serilog/wiki/Getting-Started
【问题讨论】: