/flags/gradle/gradle-stacktrace
gradle --stacktrace, --info, --debug, --scan: get more detail on a failed build
- tool
- Gradle
- command
- gradle, ./gradlew
- flag
- -s, --stacktrace; -S, --full-stacktrace; -i, --info; -d, --debug; --scan
- default
- no stack trace; log level lifecycle
When a Gradle build fails, the console shows only the error message and a "Try:" block that suggests --stacktrace, --info or --debug and --scan. ./gradlew build --stacktrace (short -s) reruns the build and prints the Java stack trace of the failure, which shows which plugin, task or script line threw it. --info (-i) and --debug (-d) raise the log level instead, and --scan uploads a browsable report. Each answers a different question, so pick the lightest one that does.
The suggestion block
A failing build ends like this:
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights../gradlew build --stacktrace # where did the exception come from?
./gradlew build --info # what did Gradle do (dependency resolution, task inputs)?
./gradlew build --info --stacktrace # both
./gradlew build --scan # shareable report with timeline and dependenciesWhich option for which question
| Option | Shows | Use when |
|---|---|---|
| -s, --stacktrace | Stack trace of the failure (filtered) | An exception without an obvious cause |
| -S, --full-stacktrace | Every frame, including Gradle internals | Reporting a Gradle or plugin bug |
| -i, --info | Info-level log: resolution, task actions, up-to-date reasons | Dependency or caching questions |
| -d, --debug | Everything, very verbose | Last resort; may contain credentials |
| -w, --warn / -q, --quiet | Fewer messages | Cleaner CI logs |
| --scan | Online report (build scan) | Sharing a failure with a team or plugin author |
| --warning-mode all | Every deprecation warning with its location | Preparing a Gradle upgrade |
Permanent settings
# gradle.properties
org.gradle.logging.level=info # quiet, warn, lifecycle, info, debug
org.gradle.warning.mode=allOn CI, add --stacktrace to the build command permanently: rerunning a failed build only to see the trace wastes time, and the trace costs nothing when the build passes.
Reading a stack trace
Look for the first Caused by: lines: the top of the trace is usually Gradle's own wrapping exception, while the cause names the real problem, for example a missing plugin repository (Plugin was not found) or a DSL mistake (Could not find method implementation()). Lines with build.gradle or build.gradle.kts and a line number point at your script.
Pitfalls
--debugoutput is huge and can include secrets from environment variables and repository credentials; never paste it unreviewed.- The options must reach the build: with a wrapper script call
./gradlew --stacktrace build; in IDEs, add them to the run configuration's arguments. - For dependency version questions, the dependencies report is clearer than
--infooutput.
FAQ
What is the difference between --stacktrace and --full-stacktrace?
--stacktrace (-s) prints the stack trace of the exception with internal Gradle frames filtered out. --full-stacktrace (-S) prints every frame, which is mainly useful when reporting a bug in Gradle or a plugin.
Is it safe to share --debug output?
Be careful. Debug logs can contain credentials, tokens and environment details. Use --info or --stacktrace for issue reports, and review any debug log before posting it.
Does --scan upload my build data?
Yes. --scan publishes a build scan to scans.gradle.com (or your Develocity server) after you accept the terms of service. Do not use it for confidential projects unless you run your own server.