Tomcat console log to a file

安稳与你 提交于 2019-12-04 03:29:54

问题


Im using Apache Tomcat 7. When I'm running Tomcat with security manager and with the -Djava.security.debug parameter I'm getting so much of text in console. I can't read the text in console. So I need the console log into some file. How can I achieve this?


回答1:


Remove ConsoleHandler from logging configuration. In conf/logging.properties:

Change this -

.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

To this -

.handlers = 1catalina.org.apache.juli.FileHandler

The logs will be in the file catalina.log.


If you want to disable console logging for selected applications, you can set swallowOutput in true in the <Context> element.

...
<Context path="..." swallowOutput="true"> 
...



回答2:


Using catalina.bat run can start the tomcat in the current console instead of a new console , so you can redirect all the standard error and standard output stream of this command to a file using

catalina.bat run > tomcat.log



回答3:


for ubuntu user, use following command:

  1. cd /opt/apache-tomcat-8.0.36/bin$
  2. ./catalina.sh run > tomcat.log

you will get the logs. Once you run this command you will get all the log files under /opt/apache-tomcat-8.0.36/logs folder..



来源:https://stackoverflow.com/questions/26359894/tomcat-console-log-to-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!