Gradle resource filtering

Gradle resource filtering I have a log4j.xml which has a dynamic property logLevel , which I need to replace based on profiles. if my profile is dev logLevel variable should be replaced by debug and so on.I have figured out how to set properties using -p , what I am trying to figure out is how to use the below

import org.apache.tools.ant.filters.ReplaceTokens

task filterFiles(type: Copy) {

from ‘src/main/resources/log4j.xml’

into ‘dist’

// Use ANT filter ReplaceTokens.

filter(ReplaceTokens, tokens: [logLevel]) }

Kindly advise