Could not get unknown property 'LoggingOutputInternal'

Hello all.

I am trying to migrate from 2.6 to 3.4.

We have the following gradle task :

task redirectOutput ( ) {
doLast {
if (!project.hasProperty(‘logFile’)) {
return;
}
def taskLog = new FileOutputStream( “$logFile”, true )
def taskError = new FileOutputStream( “$logFile”, true )

gradle.services.get(LoggingOutputInternal).addStandardOutputListener(
	new StandardOutputListener( ) {
  		public void onOutput(CharSequence output) {
			taskLog << output;
			taskLog.flush()
  		}
	}
)

gradle.services.get(LoggingOutputInternal).addStandardErrorListener(
	new StandardOutputListener( ) {
  		public void onOutput(CharSequence output) {
			taskError << output;
			taskError.flush()
  		}
	}
)
}	

}

that is broken in Gradle 3.4 with the following messages:
“Could not get unknown property ‘LoggingOutputInternal’ for task ‘:redirectOutput’ of type org.gradle.api.DefaultTask.”

Since I am newbie in Gradle, your help will be really appreciated.

Thanks in advance.
Nicholas