简体   繁体   中英

How to run java test in gradle in debug level


I built an app and build it with the gradle.
But I can't understand how to test in gradle in debug mode.

I enter:

gradle test -d > test.log

but I get only debug messages about building, not messages log.debug() from test.

log.info() messages I can see in builded test result's "Standart error" tab. But how can I see [DEBUG] messages?

  1. slf4j is only an api, you need as well an implementation
  2. Suggest to use logback-classic as implementation, by adding it in your gradle build file as a testRuntime dependency. Ref: http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html

That should do the trick. If you need more control, you can tweak logback by providing a logback(-test).xml. Ref: http://logback.qos.ch/manual/configuration.html

If you don't want to set the log level programmatically, you can setup a configuration file for java.util.logging. You can find detailed instructions here .

See the property "logger".level . Set it to FINEST to log everything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM