gradle构建中的日志消息未显示在Android Studio的gradle控制台中

时间:2018-02-09 15:21:34

标签: android android-studio android-gradle android-studio-3.0

我的build.gradle想记录消息,我试过了:

signingConfigs {
        debug {
            ...

        }

        release {
           ...
           project.logger.info("I am releasing build!");
        }
    }

buildTypes {
        debug {
            ...
        }
        release {
          signingConfig signingConfigs.release
          project.logger.info("I am releasing build too!");
        }
 }

我从构建变体中选择“release”。但是当我运行build时,我无法从Android Studio右下角的“Gradle Console”中找到日志消息。为什么? (我使用的是Android Studio 3.0.1)

enter image description here

1 个答案:

答案 0 :(得分:1)

You are logging with info level. To show info messages you have to run your tasks with --info or lower flag.

To print your message without any additional flag you should use lifecycle logging level eg project.logger.lifecycle('I am releasing build too!') or just print to System.out println('I am releasing build too!')

You may read more about logging at gradle tasks here https://docs.gradle.org/current/userguide/logging.html