Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Output SARIF diagnostics to the specified file or directory. For more information, see Structured SARIF Diagnostics.
Syntax
/experimental:log
filename
/experimental:log
directoryname\
Arguments
filename
The output file for SARIF diagnostics. The compiler automatically adds the .sarif
extension to filename. The space between /experimental:log
and filename is optional. Use double quotes around paths containing spaces. Both relative and absolute paths are supported.
directoryname\
The output directory for SARIF diagnostics (for example, /experimental:log sarif_output\
). Remember to add the trailing backslash (\
) to indicate it's a directory. Each source file name forms the base name for each SARIF file saved in the directory. The compiler automatically adds the .sarif
extension to each file name. The space between /experimental:log
and directoryname\ is optional. Use double quotes around paths containing spaces. Both relative and absolute paths are supported.
Remarks
This option is available starting in Visual Studio 2022 version 17.8.
Diagnostics are also output as text to the console as usual.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.
- Select the specific project Configuration and Platform for which you want to change the property. You can also choose "All Configurations" and "All Platforms".
- Select the Configuration Properties > C/C++ > Command Line property page.
- Modify the Additional Options property, and then choose OK.
Examples
The following command produces SARIF information for the compilation of main.cpp
and saves it in the file mySarifInfo.sarif
:
cl /experimental:log mySarifInfo main.cpp
The following command produces SARIF information for the entire compilation and saves it in the sarif_output
directory in the files main.sarif
and other.sarif
:
cl /experimental:log sarif_output\ main.cpp other.cpp