简体   繁体   English

为什么Tomcat STDOUT总是指向/ dev / null?

[英]Why would Tomcat STDOUT Always Point to /dev/null?

We're happily running three CentOS servers, each with the same application deployed on a Tomcat instance (UAT, Demo and Production). 我们很高兴地运行三台CentOS服务器,每台服务器都在Tomcat实例上部署了相同的应用程序(UAT,演示和生产)。 We use Log4j in the application to output to the standard CATALINA_HOME/logs/catalina.out file. 我们在应用程序中使用Log4j来输出到标准的CATALINA_HOME / logs / catalina.out文件。 This works perfectly on the UAT and Demo servers, but on the Production server we get output in this file up till the end of the startup process, but none of the application logging is ever output. 这在UAT和Demo服务器上可以很好地工作,但是在生产服务器上,直到启动过程结束,我们都会在此文件中获得输出,但是永远不会输出任何应用程序日志记录。

Using LSOF I can see that the STDOUT always winds up pointing to /dev/null. 使用LSOF,我可以看到STDOUT总是指向/ dev / null。 Even when explicitly starting Tomcat with >> $CATALINA_OUT 2>&1 & appended to it, it winds up pointing at /dev/null. 即使使用>> $ CATALINA_OUT 2>&1并显式启动Tomcat时,它最终指向/ dev / null。 I can see on the other servers it points to the correct catalina.out file. 我可以在其他服务器上看到它指向正确的catalina.out文件。

I have re-deployed tomcat on the server, and have directly copied the config files from the working UAT instance, and I'm now scratching my head. 我已经在服务器上重新部署了tomcat,并直接从正在工作的UAT实例中复制了配置文件,现在我正在挠头。 Any thoughts? 有什么想法吗?

How are you "starting Tomcat with >> $CATALINA_OUT 2>&1 & appended to it" ? 您如何“用>> $ CATALINA_OUT 2>&1启动Tomcat并附加到它”?

Are you 100% sure no one has modified bin/startup.sh or bin/catalina.sh to add the /dev/null behavior? 您是否100%确定没有人修改过bin/startup.shbin/catalina.sh来添加/dev/null行为?

Unrelated to your core question, but I would strongly suggest using a log4j configuration to write to a file ( FileAppender ) rather than logging to standard out - this gives you options to roll the files over based on the date/size/etc, change the location, etc, very easily. 与您的核心问题无关,但我强烈建议您使用log4j配置写入文件( FileAppender ),而不是登录标准输出-这使您可以选择根据日期/大小/等来滚动文件,更改位置等,非常容易。 Logging to standard out does not give you this flexibility. 登录到标准配置并不能为您提供这种灵活性。

You have a similar setup that does work correctly; 您有一个类似的设置可以正常工作。 the thing to do is to find out what's different about the one that doesn't. 要做的是找出没有差异的地方。 Do a diff on the following files: 对以下文件进行比较:

  • conf/logging.properties conf / logging.properties
  • bin/startup.sh bin / startup.sh
  • bin/catalina.sh bin / catalina.sh

Also compare: 还要比较:

  • The user that owns the Tomcat process, and the groups that the user belongs to. 拥有Tomcat进程的用户以及该用户所属的组。
  • File ownership and permissions on the logging directory. 日志目录中的文件所有权和权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM