相关疑难解决方法(0)

在ASP.NET Core 2.2中使用InProcess托管模型时,Serilog不会将日志写入文件

如果我使用新引入的InProcess托管模型ASP.NET Core 2.2如下:

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

Serilog不写日志到文件.但是,如果我<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>.csproj一切中删除按预期工作.

SerilogProgram课堂上的配置如下:

public class Program
{
    public static void Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Information() // Set the minimun log level
            .WriteTo.File("Logs\\log-.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7) // this is for logging into file system
            .CreateLogger();

        try
        {
            Log.Information("Starting web host");
            CreateWebHostBuilder(args).Build().Run();
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "Host terminated unexpectedly");
        }
        finally
        {
            Log.CloseAndFlush();
        }

    }

    public static …
Run Code Online (Sandbox Code Playgroud)

c# serilog asp.net-core asp.net-core-2.2

6
推荐指数
1
解决办法
1712
查看次数

标签 统计

asp.net-core ×1

asp.net-core-2.2 ×1

c# ×1

serilog ×1