STDOUT在Eclipse中出现错误

STDOUT在Eclipse中出现错误

本文介绍了Tomcat STDOUT在Eclipse中出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse(3.3.2)中配置Tomcat(5.5)服务器。一旦添加Tomcat并启动它,输出将在Eclipse控制台中打印出来。此输出以红色表示,表示其标准错误。虽然服务器启动时没有任何错误,但正常的INFO也被标记为错误。

  2010年7月29日7:06:14 PM org.apache.catalina.core.AprLifecycleListener init 
INFO:在java.library.path中找不到在生产环境中实现最佳性能的基于APR的Apache Tomcat Native库:C:\Program Files\ C ++ \\ \jre\bin\client; C:\Program Files\Java\jdk1.5.0_10\bin\..\jre\bin; C:\Program Files\CollabNet Subversion Client ; C:\Program Files\Java\jdk1.5.0_10\bin; C:\Program Files\Java\jre1.5.0_07\bin; C:\Program Files\Oracle\ Oracle9i\9201\bin; C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\Program Files\Sybase125\ OCS-12_5\bin; C:\Program Files\Sybase125\OCS-12_5\dll; C:\Program Files\Sybase125\OLEDB; C:\Program Files\Rational\ClearCase \bin; C:\Program Files\Ubsw\Wire\Core; Z:\ZUR_GCOMP_DOC\Project_Trust\datamodel\scripts\GC_trust\Release\1.36\01-DDL; K C \\ \\ Program Files \\ ; C:\Program Files\MySQL\MySQL Server 5.1\bin; C:\Program Files\apache-maven-2.2.1\bin; C:\Program Files\apache-ant- 1.7.0\bin; C:\Viral\Tech\Java\javadb / bin; C:\Program Files\JAD
2010年7月29日下午7:06:15 org.apache .coyote.http11.Http11BaseProtocol init
INFO:初始化http-8080上的Coyote HTTP / 1.1
2010年7月29日下午7:06:15 org.apache.catalina.startup.Catalina加载
信息:我在1187 ms处理的nitialization
2010年7月29日下午7:06:15 org.apache.catalina.core.StandardService启动
信息:启动服务Catalina
2010年7月29日7:06: 15 PM org.apache.catalina.core.StandardEngine start
INFO:启动Servlet引擎:Apache Tomcat / 5.5.30
2010年7月29日下午7:06:15 org.apache.catalina.core。 StandardHost start
INFO:禁用XML验证
2010年7月29日7:06:15 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO:在http-8080上启动Coyote HTTP / 1.1
2010年7月29日下午7:06:15 org.apache.jk.common.ChannelSocket init
INFO:JK:ajp13 listen on /0.0.0.0:8009
2010年7月29日7 :06:15 PM org.apache.jk.server.JkMain start
INFO:Jk running ID = 0 time = 0/110 config = null
2010年7月29日下午7:06:15 apache.catalina.storeconfig.StoreLoader加载
INFO:在classpath资源下查找注册表server-registry.xml
2010年7月29日下午7:06:15 org.apache.catalina.startup.Catalina start
信息:服务器启动在922毫秒

任何人都可以让我知道如何克服这一点,并将输出更改为BLACK作为STDOUT? p>

解决方案

它是红色的,因为它被写入标准错误( System.err )假设您正在使用正常的配置。



理论上,解决此问题的方法是调整日志配置(这似乎是 java .util.logging 为基础),因此INFO级别及以下的邮件将写入标准版。不幸的是,这比起可能是因为 ConsoleHandler 类是硬编码写入标准错误,并且如果您将写入标准和标准错误,很有可能你最终会收到不按顺序排列的日志消息。 (这很糟糕,很混乱)你可以通过子类化 StreamHandler 来修复它,并且做很多的改动 - 例如,覆盖发布所以它设置输出流,如果日志从高级别更改为低级别,反之亦然 - 但我真的怀疑,结果将是你想要的。由于在Tomcat的生产部署中,您无法登录到控制台(默认情况下会记录到文件)我建议停止担心关于这个。


I am configuring Tomcat (5.5) server in Eclipse (3.3.2). Once I add Tomcat and start it, the output is printed in Eclipse Console. This output is printed in RED indicating its Standard Error. Although the server gets started without any error the normal INFO is also marked as error.

Jul 29, 2010 7:06:14 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_10\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.5.0_10\bin\..\jre\bin\client;C:\Program Files\Java\jdk1.5.0_10\bin\..\jre\bin;C:\Program Files\CollabNet Subversion Client;C:\Program Files\Java\jdk1.5.0_10\bin;C:\Program Files\Java\jre1.5.0_07\bin;C:\Program Files\Oracle\Oracle9i\9201\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Sybase125\OCS-12_5\bin;C:\Program Files\Sybase125\OCS-12_5\dll;C:\Program Files\Sybase125\OLEDB;C:\Program Files\Rational\ClearCase\bin;C:\Program Files\Ubsw\Wire\Core;Z:\ZUR_GCOMP_DOC\Project_Trust\datamodel\scripts\GC_trust\Release\1.36\01-DDL;K:\scripts\;C:\Program Files\Ubsw\Wire\Core\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Windows Imaging\;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\apache-maven-2.2.1\bin;C:\Program Files\apache-ant-1.7.0\bin;C:\Viral\Tech\Java\javadb/bin;C:\Program Files\JAD
Jul 29, 2010 7:06:15 PM org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jul 29, 2010 7:06:15 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1187 ms
Jul 29, 2010 7:06:15 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jul 29, 2010 7:06:15 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.30
Jul 29, 2010 7:06:15 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jul 29, 2010 7:06:15 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jul 29, 2010 7:06:15 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jul 29, 2010 7:06:15 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/110  config=null
Jul 29, 2010 7:06:15 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Jul 29, 2010 7:06:15 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 922 ms

Can anyone let me know how to overcome this and change the output back to BLACK as STDOUT?

解决方案

It's in red because it's written to standard error (System.err), assuming you're using a normal configuration.

Theoretically, the way to fix this is to adjust the logging configuration (which appears to be java.util.logging based) so that messages at INFO level and below are written to standard out instead. Unfortunately, this is a little bit messier than it might be because the ConsoleHandler class is hard-coded to write to standard error, and if you mix between writing to standard out and standard error, there's a good chance that you'll end up getting the logging messages written out of order. (That's bad. Very confusing.) You could fix it by subclassing StreamHandler and doing a lot of fiddling around – e.g., override publish so it sets the output stream if logging changes from high-level to low-level or vice versa – but I really doubt that the results are going to be what you desire. It's also going to be slow.

Since in a production deployment of Tomcat you don't log to the console anyway (it logs to files by default) I suggest stopping worrying about this.

这篇关于Tomcat STDOUT在Eclipse中出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:47