从Maven插件配置嵌入式Tomcat的日志记录 [英] Configuring Logging for an Embedded Tomcat from Maven plugin
问题描述
我使用的是Tomcat7 Maven插件:
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>
我运行我的应用程序如下(运行tomcat嵌入)
I run my app as follows (which runs tomcat embedded)
mvn tomcat7:run
mvn tomcat7:run
问题:没有catalina.out log文件?
THE ISSUE: There is no catalina.out log file?
我想为Realms打开日志记录,所以我可以调试一些东西。在./target/tomcat/log目录中只有access_log。*没有其他日志文件。
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.
我试图搞乱./target/tomcat/conf /logging.properties文件无效。
I've tried messing with the ./target/tomcat/conf/logging.properties file to no avail.
如何为此Tomcat配置日志记录?
How can I configure logging for this Tomcat?
推荐答案
我发现解决方案,需要描述日志库的额外依赖。在我的情况下,它的 logback ,如果你使用log4j只是改变依赖。它工作...
下面我的配置:
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>
这篇关于从Maven插件配置嵌入式Tomcat的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!