私は5つの.netコアプロジェクト、1つのコンソールアプリケーション、残りはクラスライブラリです。主な機能のクラスのプログラムでは私が持っている:私のすべてのクラスでSerilogはファイルにログを書きません
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
の行を実行しています。今私は何をすべきか分かりません。多分誰かが似た問題を抱えていますか
EDIT 私はここhttps://github.com/serilog/serilog/wiki/Getting-Started
Omg、ありがとうございます。読んだりするとプログラムが止まってしまうのですが、なんとなく動作します。 – nju
嬉しいです。 –