0

No log file is created. What's wrong with this code? .Net Framework 4.8.

var log = new LoggerConfiguration()
        .WriteTo.File(@"d:\temp\mdlogfile.txt", rollingInterval: RollingInterval.Day)
        .CreateLogger();
//log.Information("Here I am, logging.");  // this works
var lf = LoggerFactory.Create(builder => 
          builder.AddSerilog(log).SetMinimumLevel(LogLevel.Trace));
var handler = new HttpClientHandler();
var grpcChannel = GrpcChannel.ForAddress(GrpcUrl, 
         new GrpcChannelOptions {
            HttpHandler = new GrpcWebHandler(handler),
            LoggerFactory = lf
         });
Elroy Flynn
  • 3,032
  • 1
  • 24
  • 33
  • I see no reason why using a different log sink would make any difference in terms of the behavior from the perspective of the grpc-dotnet library (unless there's something is wrong in the snippet and I've missed that). I found this article, so perhaps it helps: https://medium.com/@tunadonmez/logging-grpc-on-net-using-serilog-c40a8fbc0426. Also note that grpc-dotnet's support for .NET Framework 4.8 is limited (not all the features will work there). Ideally your application would use .NET 5+ (or at least .NET Core 3.1+) – Jan Tattermusch Jan 03 '23 at 11:56

0 Answers0