
ai.digital.integration.server.tasks.SetLogbackLevelsTask.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integratoin-server-gradle-plugin Show documentation
Show all versions of integratoin-server-gradle-plugin Show documentation
The easy way to get custom setup for Deploy up and running
The newest version!
package ai.digital.integration.server.tasks
import ai.digital.integration.server.util.DbUtil
import ai.digital.integration.server.util.LocationUtil
import ai.digital.integration.server.util.ServerUtil
import groovy.xml.QName
import groovy.xml.XmlUtil
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import static ai.digital.integration.server.constant.PluginConstant.PLUGIN_GROUP
class SetLogbackLevelsTask extends DefaultTask {
static NAME = "setLogbackLevels"
SetLogbackLevelsTask() {
this.configure { ->
group = PLUGIN_GROUP
mustRunAfter DownloadAndExtractServerDistTask.NAME
}
}
private def getHardCodedLevels() {
DbUtil.getDatabase(project).logSql ? [
"org.hibernate.SQL" : "trace",
"org.hibernate.type": "all"
] : [:]
}
@TaskAction
def setLevels() {
def server = ServerUtil.getServer(project)
project.logger.lifecycle("Setting logback level on Deploy Server.")
def logbackConfig = "${LocationUtil.getServerWorkingDir(project)}/conf/logback.xml"
def xml = new XmlParser().parse(project.file(logbackConfig))
def configuration = xml.'**'.find { it.name() == 'configuration' }
def logLevels = getHardCodedLevels() + server.logLevels
logLevels.each { Map.Entry logLevel ->
configuration.appendNode(new QName("logger"), [name: logLevel.key, level: logLevel.value])
}
XmlUtil.serialize(xml, new FileWriter(project.file(logbackConfig)))
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy