« Nlog » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
(Page créée avec « Category:.NET Application = Links = * [https://nlog-project.org/download/ Getting started] = [https://github.com/NLog/NLog/wiki/Getting-started-with-.NET-Core-2---Console-application Console project] = == Nuget packages == * {{boxx|NLog.Extensions.Logging}} * {{boxx|Microsoft.Extensions.DependencyInjection}} * {{boxx|Microsoft.Extensions.Configuration.Json}} == Config file == <filebox fn='appsettings.json'> { "NLog": { "throwConfigExceptions": true,... »)
 
Ligne 17 : Ligne 17 :
       "async": true,
       "async": true,
       "logconsole": {
       "logconsole": {
         "type": "ColoredConsole"
         "type": "ColoredConsole",
        "layout": "${longdate}|${level}|${message} |${all-event-properties} ${exception:format=tostring}"
       }
       }
     },
     },

Version du 16 mars 2023 à 14:27

Links

Console project

Nuget packages

  • NLog.Extensions.Logging
  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Extensions.Configuration.Json

Config file

appsettings.json
{
  "NLog": {
    "throwConfigExceptions": true,
    "targets": {
      "async": true,
      "logconsole": {
        "type": "ColoredConsole",
        "layout": "${longdate}|${level}|${message} |${all-event-properties} ${exception:format=tostring}"
      }
    },
    "rules": [
      {
        "logger": "*",
        "minLevel": "Info",
        "writeTo": "logconsole"
      }
    ]
  }
}