3

I am using IApplicationBuilder.UseSerilogRequestLogging() for request logging. I have configured File as sink. But it is not working. I can see every other log events but there is no Event logs that are generated by UseSerilogRequestLogging(). Even if I remove this method from the middleware pipeline, the logs are the same. I have tried to set minimum level of "Microsoft.AspNetCore" to LogEventLevel.Warning but in that case there are no logs.

I have installed Serilog, Serilog.AspNetCore nudget packages.

below is my programe.cs code

var builder = WebApplication.CreateBuilder(args);

var logger = new LoggerConfiguration()
    .WriteTo.File("Logs.txt")
    .CreateLogger();
builder.Host.UseSerilog(logger);

var app = builder.Build();
app.UseSerilogRequestLogging();

and here is my log file

1

I am trying for a long time but can't find any solution. Can anyone help?

I have tried to set minimum level of "Microsoft.AspNetCore" to LogEventLevel.Warning but in that case there are no logs.

vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

-2

Please try to include Properties in outputTemplate in SeriLog configuration.

"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception} {Properties:j}"
DinosaurTom
  • 212
  • 4
  • 15