Skip to main content

Enabling the JSON Format for Log Files

To obtain logs in JSON format, enable the JSON format in the config files for each log that provides this option.

For the Scans Manager logs, for example, enter the bin folder (C:\Program Files\Checkmarx\Checkmarx Scans Manager\bin) and locate the logging config file, in this case ScansManager.logging.config and set "jsonFormat" to true. You are able to generate logs in JSON format and the plain text format or just in JSON format. In addition, you can define which elements of the log structure to show or hide.

To generate the log in JSON format only:

  1. Navigate to the relevant bin folder, for example C:\Program Files\Checkmarx\Checkmarx Scans Manager\bin and open the logging config file, in this case ScansManager.logging.config with your text editor.

  2. Set "jsonFormat" to true.

  3. To show results for the desired elements of the JSON log, set them to true as well, for example to display the Correlation results, set "showCorrelation" to true.

  4. Save the file.

To generate the log in plain text and JSON format:

  1. Duplicate the relevant code section, for example:

          {
            "path": "$rootDir$/../../Logs/ScansManager",
             ...
              "period": "Infinite"
            }
          }
  2. In the duplicated section, under "path", define a different path, for example, for the JSON log. The path might be something like "path": "$rootDir$/../../Logs/ScansManager/JSON", while the path in the example above specifies the location for the log in plain text format.

  3. Set "jsonFormat" to true and enable the elements of the JSON log that you want to be displayed as outlined above.

  4. Save the file.

Notice

To display part or some aspects of the log (for example ERROR level in JSON format and the rest in plain text format, set "minimumLevel" to the respective level. For example, for JSON format, set "minimumLevel" to "ERROR" and for the part to be generated in plain text format, set it to "Information".

Example for the Scans Manager log:

{
  "service": {
    "identifier": "ScansManager"
  },
  "persistence": {
    "File": [
      {
        "path": "$rootDir$/../../Logs/ScansManager",
        "fileName": "CxScanManager",
        "dateTimeFormat": "yyyy-MM-dd HH:mm:ss,fff",
        "minimumLevel": "Error",
        "jsonFormat": true,
        "showCaller": true,
        "showCorrelation": true,
        "showService": true,
        "showGuid": true,
        "retention": 5,
        "rotation": {
          "size": 10,
          "period": "Infinite"
        }
      },
      {
        "path": "$rootDir$/../../Logs/ScansManager/Trace",
        "fileName": "CxScanManagerAll",
        "dateTimeFormat": "yyyy-MM-dd HH:mm:ss,fff",
        "minimumLevel": "Information",
        "jsonFormat": false,
        "showCaller": false,
        "showCorrelation": false,
        "showService": false,
        "showGuid": false,
        "retention": 5,
        "rotation": {
          "size": 10,
          "period": "Infinite"
        }
      }
    ]
  }
}