Nlog: highlight-row syntax for appsettings.json

Created on 24 Oct 2019  路  5Comments  路  Source: NLog/NLog

can you provide valid syntax for colored console target to setup multiple highlight-row settings?
thanks!

"targets": {
  "console": {
    "type": "ColoredConsole",
    "layout":"${longdate}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}",
    ??? (for multiple) "highlight-row":
      {
      "condition": "level == LogLevel.Error",
      "foregroundColor": "Red"
      } 
  },
nlog-configuration question

All 5 comments

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

Got it working? Please post the working example for others :)

Yes, I found the solution

"targets": {
  "console": {
    "type": "ColoredConsole",
    "layout":"${longdate}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}",
    "rowHighlightingRules" : [
      {
        "condition": "level == LogLevel.Debug",
        "foregroundColor": "DarkGray"
      },
      {
        "condition": "level == LogLevel.Info",
        "foregroundColor": "Gray"
      },
      {
        "condition": "level == LogLevel.Warn",
        "foregroundColor": "Yellow"
      },
      {
        "condition": "level == LogLevel.Error",
        "foregroundColor": "Red"
      },
      {
        "condition": "level == LogLevel.Fatal",
        "foregroundColor": "Red",
        "backgroundColor": "White"
      }
    ]

Thanks!

Updated the advanced JSON-example to include this:

https://github.com/NLog/NLog.Extensions.Logging/wiki/Json-NLog-Config

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sam13 picture Sam13  路  3Comments

ericnewton76 picture ericnewton76  路  3Comments

ErcinDedeoglu picture ErcinDedeoglu  路  3Comments

vasumsit picture vasumsit  路  3Comments

smeegoan picture smeegoan  路  3Comments