如何从Maven插件'tomcat7-maven-plugin'配置嵌入式Tomcat的日志记录 [英] How to configure Logging for an Embedded Tomcat from Maven plugin 'tomcat7-maven-plugin'
问题描述
我将Maven 3.0.4与tomcat7-maven-plugin一起用于嵌入式Tomcat服务器.我想通过编辑pom.xml生成服务器日志.但是,在配置部分中,我无法通过"tomcatLoggingFile"属性获取任何日志.下面是我的配置:
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>
我已经检查了tomcat7-maven-plugin的官方文档: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/run-mojo.html 但仍然不知道为什么它不起作用.
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.
我还检查了此帖子:配置日志记录从Maven插件中获取嵌入式Tomcat 并改用org.slf4j.LoggerFactory.在文件tomcat_server.log中找不到任何日志.
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.
当我转回在pom.xml中使用jboss-as-maven-plugin并运行mvn jboss-as:run
时,可以在目标文件夹内成功生成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.
有什么建议吗?
推荐答案
由于错误,嵌入式Tomcat Maven的日志记录配置当前已损坏
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
这篇关于如何从Maven插件'tomcat7-maven-plugin'配置嵌入式Tomcat的日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!