Tomcat Gradle Plugin logs


(abhishek agrawal) #1

Hi, I am using gradle tomcat plugin for my web application and I am having issues with getting console and other logs in the declared outputFIle. There are no console or catalina.out logs inside the declared outputFile. I want to know where the catalina.out logs get captured.

Also, how to integrate log4j logs with your plugin. With the default setting of log4j.xml, it is working if used with external tomcat , but not with the embedded tomcat with your plugin.

My build.gradle =================================================================================================================

apply plugin: ‘java’ apply plugin: ‘tomcat’

repositories {

maven {

url ‘http://192.168.5.56/resources/localrep

artifactUrls ‘http://192.168.5.56/resources/extrep

}

mavenCentral() }

buildscript {

repositories {

jcenter()

}

dependencies {

classpath ‘org.gradle.api.plugins:gradle-tomcat-plugin:1.0’

} }

dependencies {

compile group:“clari5.platform”, name: “rdbms”, version: “SNAPSHOT”

compile group:“com.google.code.gson”, name: “gson”, version: “2.2.4”

compile group:“log4j”, name: “log4j”, version: “1.2.14”

providedCompile group:“org.apache.tomcat”, name:“tomcat-catalina”, version:“7.0.47” }

dependencies {

def tomcatVersion = ‘7.0.47’

tomcat “org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}”,

“org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}”

tomcat(“org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}”) {

exclude group: ‘org.eclipse.jdt.core.compiler’, module: ‘ecj’

} }

tomcatRun {

daemon = true

httpPort = 5000

stopKey = ‘rbi’

outputFile = file(‘logs/tomcat.log’)

webDefaultXml = file(‘src/main/webapp/WEB-INF/web.xml’) }

tomcatStop {

stopKey = ‘rbi’ }


(Benjamin Muschko) #2

System.out.println is not captured by the plugin. It will still go to the console that runs Gradle. Keep in mind that the embedded Tomcat container runs in the same JVM as Gradle. If you want the standard behavior of a Tomcat installation, you might rather want go for the Cargo plugin.