To start in debug mode use the command line
R17.12 and R18.12
Trunk and after R18.12
gradlew ofbiz --debug-jvm
This run in debug mode listening for a socket connection on port 5005 for a debugger to connect. So unlike with Ant you have to connect a Debugger at this port for OFBiz to continue.