Scan in Debug Mode to Troubleshoot
Run cnspec in debug mode, collect a support bundle, and control log levels for troubleshooting
If a cnspec scan isn't behaving as expected, you can run it in debug mode to capture detailed information about what happened. Debug mode creates files that you can share with Mondoo support to help diagnose the problem.
Collect a support bundle
The quickest way to gather everything Mondoo support needs is the --collect-support-bundle flag:
cnspec scan local --collect-support-bundlecnspec runs the scan with debug logging, then packs the debug log, the asset bundle, the inventory, the resolved policy, the report, and the installed provider versions into a single archive in the current directory. It prints the archive's path when it finishes:
support bundle written to: /home/lunalectric/cnspec-support-bundle-20260924T173422Z.tar.gzTo write the bundle somewhere else, add --support-bundle-dir:
cnspec scan aws --collect-support-bundle --support-bundle-dir /tmp/cnspec-supportRun a debug scan
To scan in debug mode without building a bundle, set the DEBUG=1 environment variable before the cnspec scan command:
DEBUG=1 cnspec scanYou can use debug mode with any scan target. For example, to debug an AWS scan:
DEBUG=1 cnspec scan aws --region us-east-1Or an Oracle Cloud Infrastructure scan:
DEBUG=1 cnspec scan ociTo learn more about scan targets, read the cnspec scan CLI reference.
Debug output files
With DEBUG=1, cnspec writes its debug data to a timestamped directory, such as cnspec-debug-20260924T173406Z, inside the directory from which you run the scan. The directory holds files for the whole run, such as report.json, assets-resolved.json, and mondoo-debug-inventory-unresolved.json, plus one subdirectory per scanned asset with that asset's resolved policy and filters.
cnspec sbom, cnspec vuln, and cnspec aibom also honor DEBUG=1. They write to cnspec-sbom-debug-*, cnspec-vuln-debug-*, and cnspec-aibom-debug-* directories.
Control log output
To raise the log level without writing debug files, use the --log-level flag. It accepts error, warn, info (the default), debug, and trace:
cnspec scan local --log-level debugEnvironment variables override the flag. MONDOO_LOG_LEVEL accepts any of those levels, and DEBUG=1 and TRACE=1 set debug and trace.
For full control over where and how cnspec logs, point --logging-config at a YAML or JSON file. It selects the log writer, the level, and options for that writer. For example, to write JSON log lines at the warn level:
writer: cli
level: warn
options:
format: jsoncnspec scan local --logging-config logging.yml| Field | Description |
|---|---|
writer | cli (the default) writes to the terminal. stackdriver sends logs to Google Cloud Logging. |
level | error, warn, info, debug, or trace. |
options | For cli, format is json or gcp-json (omit it for the colorized console output). For stackdriver, project-id and log-id are required. |
labels | Key-value labels added to every log entry by the gcp-json format and the stackdriver writer. |
A logging configuration file takes precedence over --log-level. The MONDOO_LOG_LEVEL, DEBUG, and TRACE environment variables still override the level it sets.
Share debug files with Mondoo
To get troubleshooting help, send the support bundle archive, or the whole cnspec-debug-* directory, to Mondoo support.
Debug output files can contain sensitive data. Do not share them anywhere public, such as a public repository or channel.
Learn more
-
To learn about scanning, read cnspec scan.
-
To report scan results, read Report Results.