Bill B
Bill B

Reputation: 37

No logging with test-app; Grails 3.2.9

I am not getting any output from log.info or log.debug statements when running test-app like so: grails test-app --info --debug -echoOut -echoErr

This was a new 3.2.9 project created using the grails cli.

My logback.groovy is

conversionRule 'clr', ColorConverter
conversionRule 'wex', WhitespaceThrowableProxyConverter

// See http://logback.qos.ch/manual/groovy.html for details on configuration
appender('STDOUT', ConsoleAppender) {
    encoder(PatternLayoutEncoder) {
        charset = Charset.forName('UTF-8')

        pattern =
                '%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} ' + // Date
                        '%clr(%5p) ' + // Log level
                        '%clr(---){faint} %clr([%15.15t]){faint} ' + // Thread
                        '%clr(%-40.40logger{39}){cyan} %clr(:){faint} ' + // Logger
                        '%m%n%wex' // Message
    }
}

def targetDir = BuildSettings.TARGET_DIR
if (Environment.isDevelopmentMode() && targetDir != null) {
    appender("FULL_STACKTRACE", FileAppender) {
        file = "${targetDir}/stacktrace.log"
        append = true
        encoder(PatternLayoutEncoder) {
            pattern = "%level %logger - %msg%n"
        }
    }
    logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
}
//root(ERROR, ['STDOUT'])
root(INFO, ['STDOUT'])

The run outputs the abbreviated result of the tests but no log messages. The output suggests using --debug or --info but like shown above I'm using them and they're not helping.

If I use --stacktrace then the output just finishes with the org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':test' stacktrace - nothing helpful.

This is basically stock so I don't understand why I'm having such a problem. One possible caveat is that I'm running a Cygwin shell under Windows 10.

Upvotes: 1

Views: 1302

Answers (1)

James Kleeh
James Kleeh

Reputation: 12238

Gradle suppresses stdout for testing

See here for a way to enable it https://stackoverflow.com/a/9357286/1264846

Upvotes: 2

Related Questions