Serilog到文件ReadFrom.Configuration

时间:2018-12-04 15:30:26

标签: serilog

我具有以下appsettings配置,但没有看到正在生成的任何文件:

"Serilog": { "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning" } }, "WriteTo": [ { "Name": "Async", "Args": { "configure": [ { "Name": "File", "Args": { "path": "CaseManagement1.log", "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}
[{Level:u3}] [{Properties}] {Message:lj} {NewLine}{Exception}" } } ] } } ], "Enrich": [ "FromLogContext"] }
在Startup.cs中,ConfigureServices事件中包含以下内容:

`

        var configuration = new ConfigurationBuilder()
        .AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
        .Build();


    services.AddScoped<Serilog.ILogger>
    (x => new LoggerConfiguration()
        .ReadFrom.Configuration(configuration)
        .CreateLogger());

`

我正在运行以下内容:

  • .net core 2.1.5,
  • Serilog.AspNetCore 2.1.1,
  • Serilog.Settings.Configuration 3.0.1,
  • Serilog.Sinks.Async 1.3.0,
  • Serilog.Sinks.File 4.0.0

谢谢

0 个答案:

没有答案