首页 > 解决方案 > Serilog Request logging is not outputting endpoint data

问题描述

I started setting up my project to use Serilog Request logging using this tutorial. I see the message that I log before calling the CreateHostBuilder() method, but according to the article, the console should show the endpoints and HTTP requests. However, none of that is showing. I've tried both Kestrel and IIS Express. I'm not sure what's going on.

I suspect the problem has something to do with my Startup.cs file, as the app I'm working with (GrandNode) is different from the example app in the tutorial. Here is the Configure() method from Startup.cs:

public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)
            {
                application.UseSerilogRequestLogging();
                application.ConfigureRequestPipeline(webHostEnvironment);
            }

Here is my Main method in Program.cs:

    public static void Main(string[] args)
            {
                Log.Logger = new LoggerConfiguration()
                    .MinimumLevel.Debug()
                    .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                    .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
                    .Enrich.FromLogContext()
                    .WriteTo.Console()
                    .WriteTo.Seq("http://localhost:5341")
                    .CreateLogger();
                try
                {
                    Log.Information("Starting up host 555");
                    CreateHostBuilder(args).Build().Run();
                }
                catch (Exception ex)
                {
                    Log.Fatal(ex, "Host terminated unexpectedly");
                }
                finally
                {
                    Log.CloseAndFlush();
                }
            }

Any help here would be great!

标签: c#asp.net-coreserilog

解决方案


推荐阅读