How to Redirect output to file

I want to redirect the output of my gradle builds to file and I found this code suggestion:

The problem I have is that gradle is not able to recongnize LoggingOutputInternal

The actual error:
“Could not get unknown property ‘LoggingOutputInternal’ for root project ‘TestCode’ of type org.gradle.api.Project.”

What do I need to add to my dependency list to be able to use it?