Configuring Logging for an Embedded Tomcat from Maven plugin

geemang picture geemang · May 23, 2012 · Viewed 13.4k times · Source

I'm using the Tomcat7 Maven plugin:

<plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0-beta-1</version>
            <configuration>
                    <update>true</update>
                    <contextFile>${basedir}/conf/context.xml</contextFile>
                    <tomcatUsers>${basedir}/conf/tomcat-users.xml</tomcatUsers>
            </configuration>
 </plugin> 

I run my app as follows (which runs tomcat embedded)

mvn tomcat7:run

THE ISSUE: There is no catalina.out log file?

I want to turn on logging for the Realms so I can debug something. In the ./target/tomcat/log dir there is only access_log.* no other log files.

I've tried messing with the ./target/tomcat/conf/logging.properties file to no avail.

How can I configure logging for this Tomcat?

Answer

Serhii Bohutskyi picture Serhii Bohutskyi · Dec 9, 2013

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>