0

I'm following the instructions here https://github.com/serilog/serilog-aspnetcore, but in the end no MVC events are getting logged, even though the minimum level was set to Verbose. Any ideas what am I doing wrong?

I'm using ASP.NET Core 2 with the following settings:

    public static int Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Verbose()
            .MinimumLevel.Override("Microsoft", LogEventLevel.Verbose)
            .Enrich.FromLogContext()
            .WriteTo.Console()
            .CreateLogger();

       // here goes the rest of init
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .UseSerilog()
            .Build();
5
  • 2
    Are you missing services.AddLogging in Startup.cs? Commented Feb 19, 2018 at 9:22
  • Please share code for Startup class, as @HansKilian pointed out, issue might be in there. Commented Feb 19, 2018 at 9:29
  • According to this link github.com/serilog/serilog-aspnetcore all calls to AddLogging should be removed from Startup class. So there's nothing to show. I rekon a call to UseSerilog() handles all that stuff Commented Feb 19, 2018 at 9:44
  • Oh, I didn't realize configuration was changed. Your config looks OK. I actually created empty project to confirm it. Try to check utput setting, as recommended in first answer. Commented Feb 19, 2018 at 13:22
  • Was there ever a resolution on this? I'm having exactly the same issue and getting nowhere. Commented Oct 2, 2019 at 22:34

1 Answer 1

1

The configuration looks OK. I am using the same ... are you looking in the right place for the logs?

With this configuration the logs will be shown in the 'Output' window in Visual Studio while debugging. Keep in mind that you must switch the output window from 'Debug' to 'ASP.NET Core Web Server' mode.

enter image description here

NOTE: I am using the Literate but it should be the same.

If you still don't see any output, try to remove this line and check again. (I have blurry memory about the same issue which was gone after i removed the overrides)

.MinimumLevel.Override("Microsoft", LogEventLevel.Verbose)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.