I can't generate the log file on MAUI app [SOLVED]

70 Views Asked by At

I use the serilog-sinks-file package to copy the logs into a ".log" file but it does not generate the directory or the file.

I added this code in "MauiProgram.cs" inside a empty MAUI project:

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Information()
    .WriteTo.Debug()
    .WriteTo.File("Logs/Test-.log")
    .CreateLogger();

Is any configuration missing?

Thank you in advance.

Versions used:

  • Serilog.Extensions.Logging 8.0.0
  • Serilog.Sinks.Debug 2.0.0
  • Serilog.Sinks.File 5.0.0
  • net8.0

UPDATE:

Solved! My problem was that I wasn't managing the routes properly.

File system helpers should be used to retrieve the directory where the application is located: FileSystem.Current.AppDataDirectory


0

There are 0 best solutions below