I\'m using the Tomcat7 Maven plugin:
org.apache.tomcat.maven
tomcat7-
My solution is,
String logBackfile ="....."; //the logback config
LoggerContext lc = new LoggerContext();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(logBackfile);
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
Try using
<tomcatLoggingFile>log.txt</tomcatLoggingFile>
in configuration section.
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
This is only a partial answer, but I got it working like this, where my app contains its own logback dependencies (no need to declare extraDependencies).
The only caveat here is that I still am not able to get the Tomcat catalina.log output that I need when there is a lower level error in my application (before the app loads and/or other). With this configuration, I only get my application level log file (not the logs/catalina.out that I really want):
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version><!-- Tomcat 7.0.47 -->
<configuration>
<port>9090</port>
<path>/${project.artifactId}</path>
<systemProperties>
<spring.profiles.active>webService</spring.profiles.active>
<java.util.logging.config.file>src/integration-test/resources/logback.xml</java.util.logging.config.file>
</systemProperties>
</configuration>
<executions>
<execution>
<id>tomcat-run</id>
<goals>
<goal>run-war-only</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>tomcat-shutdown</id>
<goals>
<goal>shutdown</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
I found solution, you need describe extra dependencies of your logging library. In my case its logback, if you use log4j just change dependencies. It works... below my config:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/myapp</path>
<extraDependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.7</version>
</dependency>
</extraDependencies>
</configuration>
</plugin>