0

I am trying to use Serilog to add exception logging to a project (.Net Core). But the location I am giving for the log file is a local path on my system. How do I make it so that no matter who has the project the logs are saved?

This is my appsettings.json setting for serilog:

"Serilog": {
    "Using": [ "Serilog.Sinks.File" ],
    "MinimumLevel": {
      "Default": "Debug",
      "Override": {
        "Microsoft": "Error",
        "System": "Debug"
      }
    },
    "Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
    "WriteTo": [
      {
        "Name": "File",
        "Args": {
          "path": "Logs\\RestApiLog.log",
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] [{SourceContext}] [{EventId}] {Message}{NewLine}{Exception}",
          "rollOnFileSizeLimit": true,
          "fileSizeLimitBytes": 4194304,
          "retainedFileCountLimit": 15,
          "rollingInterval": "Minute"
        }
      }
    ]
  },
  • what issue are you facing ? it is not clear from your question . – CodingMytra Mar 17 '23 at 09:47
  • @CodingMytra I want to make the path the log file is created generic (Instead of the my local path that I am giving rn). So that it will make a file at the given location on the project – Ibrahim Bhatty Mar 20 '23 at 04:46
  • to me it already seems generic, what problem did you faced ? – CodingMytra Mar 20 '23 at 04:50
  • @CodingMytra Please refer to https://stackoverflow.com/questions/75786934/files-not-being-created-in-the-right-directory-serilog . I have included my full implementation – Ibrahim Bhatty Mar 20 '23 at 05:56

0 Answers0