Logging output contains extra blank lines

issue-acknowledged
gradle-3560

(Hendrik Haddorp) #1

Hi,
my test code is using log4j2 to print out things during the test execution. If I use the the highlighting mode of log4j2 I get extra blank lines after every log line.

My log pattern is defined like this:

<PatternLayout pattern="%highlight{%date{HH:mm:ss.SSS} [%threadName] %-5level %class{36}:%line %method - %message%throwable%n}"/>

If I use this:

<PatternLayout pattern="%date{HH:mm:ss.SSS} [%threadName] %-5level %class{36}:%line %method - %message%throwable%n"/>

The output looks correct.

I can also make it look correct by leaving the newline at the end of my pattern away but then it doesn’t work in all other places anymore, like in Eclipse (using the ANSI console).

regards,
Hendrik


(Jendrik Johannes) #2

Hi Hendrik,

I can reproduce the problem. The issue here seems to be that the logging is processed through Gradle’s test logging infrastructure which processes messages to standard out line by line. My assumption is it interprets the formatting characters following the \n in a log message as more characters to be printed in the next line and then adds another newline at the end of the message, thus leading to two new lines in total.

Defining the pattern like this (putting %n in the very end) is a workaround:

<PatternLayout pattern="%highlight{%date{HH:mm:ss.SSS} [%threadName] %-5level %class{36}:%line %method - %message%throwable}%n"/>

I opened a bug report: https://issues.gradle.org/browse/GRADLE-3560


(Hendrik Haddorp) #3

Thanks, that looks a lot better!