Get Appsettings not app.config ?

Get Appsettings not app.config ?

a.burgaudeau
Observer Observer
344 Views
1 Reply
Message 1 of 2

Get Appsettings not app.config ?

a.burgaudeau
Observer
Observer

Hi !

I want to setup a logging service with Configuration file. With  Microsoft we must used inject dependency...

To do that I need "Getsection" in the AppSettings.json.

I follow this page : here 

ServicesBuilder :

            services.AddLogging(loggingBuilder =>
            {
                loggingBuilder.CodeFileLogger(options =>
                {
                    Configuration.GetSection("Logging").GetSection("CodeFile").GetSection("Options")
                        .Bind(options);
                });
            });

AppSettings :

{
  "Logging": {
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    },
    "CodeFile": {
      "Options": {
        "FolderPath": "Logs",
        "FilePath": "log_{date}.log"
      },
      "LogLevel": {
        "Default": "Debug",
        "System": "Information",
        "Microsoft": "Information",
        "LicenceManager.API.Controllers.Controllers": "Information",
        "LicenceManager.API.Controllers.Services": "Information"
      }
    }
  }
}

 

Thx !

 

345 Views
1 Reply
Reply (1)
Message 2 of 2

moturi.magati.george
Autodesk
Autodesk

Hi @a.burgaudeau,

 

Please note that this discussion forum is dedicated to programming Revit using the Revit API.

 

I am not able to clearly understand your question but if you want to split your log data into different files, you can try to read here https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-7.0

You can also use serilog package to achieve the same result as explained here https://github.com/serilog/serilog with a simple log splitting example here https://vmsdurano.com/serilog-and-asp-net-core-split-log-data-using-filterexpression/ 

 

  Moturi George,     Developer Advocacy and Support,  ADN Open
0 Likes