Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Logging for an Embedded Tomcat from Maven plugin

Tags:

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?

like image 643
geemang Avatar asked May 23 '12 20:05

geemang


People also ask

What is tomcat7 Maven plugin?

The Tomcat7 Maven Plugin provides goals to manipulate WAR projects within the Tomcat servlet container version 7.x.

Does maven have Tomcat?

Like many of its functionalities, Maven provides Tomcat-specific goals through the use of independently developed plugins. There are currently two Tomcat plugins available for Maven.

How do I deploy a Maven project from Tomcat to eclipse?

Right-click the maven project, click Run As —> Run Configurations menu item. Input clean install tomcat7:deploy in the Goals input text box deploy maven project to tomcat. Click Run button, when you see BUILD SUCCESS in the output console, that means the maven deploy to tomcat server process complete successfully.


1 Answers

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>
like image 161
Serhii Bohutskyi Avatar answered Oct 12 '22 22:10

Serhii Bohutskyi