datalust/dotnet6-serilog-example

How could I log the trace level in an ASP Core .NET 6 application?

ComptonAlvaro opened this issue · 2 comments

When I use the default configuration of Serilog (the code example for ASP Core .NET 6) I get this log:

[10:57:21 INF] Starting up
[10:57:21 WRN] Overriding address(es) 'http://localhost:5130, https://localhost:7130'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
[10:57:21 INF] Now listening on: https://[::]:5001
[10:57:21 INF] Application started. Press Ctrl+C to shut down.
[10:57:21 INF] Hosting environment: Development
[10:57:21 INF] Content root path: D:\desarrollo\proyectos\GestorOrdenadores\GestorOrdenadores.Service.Server.Host.AspCore\

But I would like to have more level of trace, I would like to can log this that I see in the console:

trce: Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilder[2]
      Discovering gRPC methods for GestorOrdenadores.Service.Server.Grpc.GestorOrdenadoresService.
trce: Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilder[1]
      Added gRPC method 'SayHello' to service 'greet.Greeter'. Method type: Unary, HTTP method: POST, route pattern: '/greet.Greeter/SayHello'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Overriding address(es) 'http://localhost:5130, https://localhost:7130'. Binding to endpoints defined via IConfiguration and/or UseKestrel() instead.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://[::]:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: D:\desarrollo\proyectos\GestorOrdenadores\GestorOrdenadores.Service.Server.Host.AspCore\

But I am not able to get this log.

How could I get it?

Thanks.

Hi! It looks like you want to adjust the logging levels in appsettings.json:

https://github.com/datalust/dotnet6-serilog-example/blob/dev/appsettings.json#L4

Setting a minimum level of Verbose, and removing the Microsoft overrides, will get everything flowing through.

HTH!

Thanks so much. This works as expected.

Thank you.