microsoft / windows-container-tools

Collection of tools to improve the Windows Containers experience
MIT License
240 stars 68 forks source link

Custom JSON Log Sanitization #128

Closed CharityKathure closed 1 year ago

CharityKathure commented 1 year ago

Task: Sanitize custom JSON Logs

For users who might want to specify their own custom JSON log format, they can do so by:

  1. Specifying the logFormat as 'custom'
  2. Adding '|json' suffix after the desired custom log format. This is to specify the sanitization method, to aid in validating the log outputs.

Sample configuration:

{
  "LogConfig": {
    "logFormat": "custom",
        "sources": [
          {
                "type": "ETW",
                "eventFormatMultiLine": false,
                "providers": [
                  {
                     "providerName": "Microsoft-Windows-WLAN-Drive",
                    "providerGuid": "DAA6A96B-F3E7-4D4D-A0D6-31A350E6A445",
                    "level": "Information"
                   }
                 ],
                "customLogFormat": "{'TimeStamp':'%TimeStamp%', 'source':'%Source%', 'Severity':'%Severity%', 'ProviderId':'%ProviderId%', 'ProviderName':'%ProviderName%', 'EventId':'%EventId%', 'Message':'%Message%'}|json"
          }
        ]
  }
}