« Nlog » : différence entre les versions

De Banane Atomic
Aller à la navigationAller à la recherche
Ligne 10 : Ligne 10 :


== Config file ==
== Config file ==
{{warn | Be sure to have the config file copied to the output folder while building.}}
<filebox fn='appsettings.json'>
<filebox fn='appsettings.json'>
{
{

Version du 16 mars 2023 à 14:28

Links

Console project

Nuget packages

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

Config file

Be sure to have the config file copied to the output folder while building.
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"
      }
    ]
  }
}