Currently available only for the pvs-studio-analyzer utility.
Diagnostic logging is designed for quick collection of reproducible information about the analyzer run: actual parameters, environment, execution result, and details about which files were analyzed or skipped.
The result is saved as a structured log (JSON), which is convenient for reading, automated processing, and submitting to technical support.
If you encounter problems with the analyzer (crashes, abnormal termination, and other scenarios that prevent normal use of PVS-Studio), attach the obtained logs when contacting technical support. You can contact technical support via the form on the website.
Structured log is a text file containing diagnostic information in JSON format. Suitable for machine processing.
Raw log is a text file with intermediate information from which the structured log is formed. Has the suffix *-raw.PVS-Studio.log. The file is not intended for self-troubleshooting.
Analyzer (frontend) — pvs-studio-analyzer (CompileCommandsAnalyzer);
Executor (of the analysis; is started by the analyzer) — pvs-studio.
It is recommended to enable diagnostic logging if:
1) Run analysis with generation of a structured log:
pvs-studio-analyzer analyze <your_usual_analysis_flags> \
--enable-logging ./pvs-diag.json
After execution, the following will appear:
./pvs-diag.json;./*-raw.PVS-Studio.log.If the structured log was not generated (due to any error), start the conversion manually:
pvs-diag-collector convert --input ./pvs-diag-raw.PVS-Studio.log \
--output ./pvs-diag.json
pvs-diag-collector utility or sent to support.--enable-logging <file_path> is a mandatory flag that enables logging and saves the structured JSON log to the specified file.
Logging options
Options are set using the --logging-options <option1,option2,...> flag. Values are passed separated by commas, without spaces.
Correct version:
--logging-options skip-sensitive,dump-intermediate-files
Incorrect version:
--logging-options skip-sensitive, dump-intermediate-files
Available options:
|
No. |
Option |
Description |
|---|---|---|
|
1 |
|
Minimizes and partially masks sensitive data in logs. For example, environment variable values and some artifacts—depending on the analysis scenario. |
|
2 |
|
Saves intermediate files after analysis—for example, preprocessed |
|
3 |
|
Adds extended information about executed runs to the structured log, if available in the collected data. |
Examples (bash):
pvs-studio-analyzer analyze <your_usual_flags> \
--enable-logging ./pvs-diag.json \
--logging-options skip-sensitive,dump-intermediate-files,embed-runs
pvs-diag-collector is a utility for collecting/processing logs and related artifacts of PVS-Studio analyzer operation.
The convert command of the pvs-diag-collector utility converts the analyzer raw log (*-raw.PVS-Studio.log) into a structured one.
In a normal workflow, these actions are performed by the analyzer automatically.
Usage
pvs-diag-collector.exe convert [FILE] [-i <FILE>] [-o <FILE>]
[--embed-runs] [-j <NUM>]
Utility options
|
No. |
Option |
Description |
|---|---|---|
|
1 |
|
Path to the input raw log. |
|
2 |
|
Path to the output structured log. If the option is not specified, the result is output to |
|
3 |
|
Adds extended information about executed runs to the structured log, if available in the collected data. |
|
4 |
|
Number of threads (by default the number is 1). When used without an argument or with the |
Examples
# Output to a file with detailed information about executor operations
pvs-diag-collector convert --input ./pvs-diag-raw.PVS-Studio.log \
--output ./pvs-diag.json \
-–embed-runs
# Output to a file
pvs-diag-collector convert --input ./pvs-diag-raw.PVS-Studio.log \
--output ./pvs-diag.json
# Output to console
pvs-diag-collector convert --input ./pvs-diag-raw.PVS-Studio.log
Return codes
0 is success;1 is an error (error text also outputs).The main fields and hints for typical problems are described below. A complete description of all fields is in the JSON schema (see the section about viewing in the editor).
It is usually useful to start with the following fields:
basicPerformance indicates time and memory;configuration — actual analyzer settings;environment indicates OS/platform/environment variables;input indicates actual launch arguments, used settings and configurations;output is a return code, stdout/stderr, indicators of problems;runs indicates, which files were analyzed/failed/skipped;utility indicates, which utility generated the log, its version, and path.During the conversion of raw analyzer logs, "anomalies" may be detected—these are hints about potential problems—output in stderr, unsuccessful statuses, version mismatches, etc.
They can be found in output.anomalies.
An anomaly is not always an error, but almost always a useful signal for checking and contacting technical support.
This section indicates typical logging use cases and log fields to pay attention to.
Analysis finished with an error / crashed:
output.returnCode;output.stderr and output.stdout;output.anomalies (if present).File was not included in the analysis (skipped):
runs.skipped[];runs.skipped[].sourceFilePath;runs.skipped[].skipReason;input.Need to confirm the actual launch configuration:
input.arguments;configuration;runs.executed[].stages.analysis.details sections of the final configuration in executor logs.Performance issue;
basicPerformance.elapsedTime;basicPerformance.peakMemoryConsumption.The structured log contains a $schema field. If the editor can get the JSON schema, it will:
Recommended scenario
$schema is accessible in the corporate network/internet—according to your policy. If the file at the specified link is unavailable, change the link to the same file in the analyzer distribution.$schema is restricted by corporate policy, it usually helps to publish the schemas on an internal artifact server (intranet) or install the schemas locally with mapping in VS Code settings (json.schemas parameter). You can also change the link to the same file in the analyzer distribution.Links to these files are written into the $schema field of each structured log. If for some reason you cannot access them locally, use the links below:
Diagnostic logs may contain confidential information:
If passing such information is critical, use --logging-options skip-sensitive, which minimizes and partially masks sensitive data in logs. Also follow these steps:
Recommended set:
*.json), specified in --enable-logging;*.PVS-Studio.i) related to the problematic file (will appear after specifying the --dump-intermediate-files option);*.PVS-Studio.cfg) related to the problematic file (will appear after specifying the --dump-intermediate-files option);*.PVS-Studio.stacktrace.txt);Analyzer structured log
Saved exactly at the path a user specified in --enable-logging.
Executor structured log
Not created separately; embedded into the analyzer structured log when the embed-runs option is specified.
Analyzer raw log
Saved in the same directory as the file from --enable-logging, but with the suffix *-raw.PVS-Studio.log.
Executor raw log
Executor raw logs are saved next to the analyzed source files. Their common feature is that the filename ends with *-raw.PVS-Studio.log.
How to find all raw logs in a project
Linux/macOS (bash):
find <project_folder> -name '*-raw.PVS-Studio.log'
Windows PowerShell:
Get-ChildItem -Path <project_folder> -Recurse -Filter "*-raw.PVS-Studio.log"
Yes, all files are text files. You can open any of them and view the contents.
Find the analyzer raw log next to the --enable-logging path.
Run the conversion manually:
pvs-diag-collector convert --input <path_to_raw_log> --output ./pvs-diag.json
If the conversion fails, send the raw log to support.
By default, temporary files and raw logs are deleted when the analysis is completed. Raw logs are saved (not deleted) if at least one of the following conditions is met:
--logging-options dump-intermediate-files option is enabled;Practical outcome: even in case of a crash, a user still has raw logs that can be converted or sent to support in their original form.
Yes. The structured log is a valid JSON, suitable for parsing.
If you need to integrate conversion into a pipeline, use pvs-diag-collector convert and check the return code (0/1).
Open the JSON in VS Code: $schemaallows you to see hints for fields and valid values. This speeds up navigation and reduces the risk of errors in interpretation.