Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Logging for an Embedded Tomcat from Maven plugin 'tomcat7-maven-plugin'

I'm using Maven 3.0.4 with tomcat7-maven-plugin for embedded Tomcat server. I would like to generate the server log through editing pom.xml. However, I can't get any log with the "tomcatLoggingFile" property in the configuration section. Below is my configuration:

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <tomcatLoggingFile>tomcat_server.log</tomcatLoggingFile>
    </configuration>
</plugin>

I've checked the official documentation for tomcat7-maven-plugin: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/run-mojo.html but still don't know why it's not working.

Also, I've checked this post: Configuring Logging for an Embedded Tomcat from Maven plugin and use org.slf4j.LoggerFactory instead. There is no any log found in the file tomcat_server.log.

When I switch back to use jboss-as-maven-plugin in pom.xml and run mvn jboss-as:run, the server.log can be generated inside target folder successfully.

Any suggestion?

like image 487
user2313900 Avatar asked Jun 07 '13 03:06

user2313900


2 Answers

The documentations says, that tomcatLoggingFile refers to "the path of the Tomcat logging configuration", not the logging file itself. Besides you shall ensure, that the logging libraries are on the classpath. See http://tomcat.apache.org/tomcat-7.0-doc/logging.html

like image 143
Matthias M Avatar answered Nov 12 '22 17:11

Matthias M


The logging configuration for Embedded Tomcat Maven is currently broken due to bug

https://issues.apache.org/jira/browse/MTOMCAT-127

The workaround is to simply redirect the stdout, like:

mvn tomcat7:run 2>&1 | tee catalina.out
like image 28
Victor Lyuboslavsky Avatar answered Nov 12 '22 19:11

Victor Lyuboslavsky