我正在Eclipse(3.3.2)中配置Tomcat(5.5)服务器。添加Tomcat并启动它后,输出将输出到Eclipse Console中。此输出以红色打印,指示其标准错误。尽管服务器启动时没有任何错误,但正常的INFO也被标记为错误。
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
谁能让我知道如何克服这个问题,然后将输出改回为STDOUT的BLACK?
它以红色表示,因为System.err假定您使用的是正常配置,它会写入标准错误()。
System.err
从理论上讲,解决此问题的方法是调整日志记录配置(似乎是java.util.logging基于日志的),以便将INFO级别及以下级别的消息改写为标准输出。不幸的是,这有点麻烦,因为ConsoleHandler该类是硬编码的,可以写入标准错误,而且如果您在写入标准输出和标准错误之间混合使用,那么很有可能最终得到记录消息乱写。(这很糟糕。非常令人困惑。)您可以通过子类化StreamHandler和进行很多修改来解决它- 例如,重写,publish以便在日志记录从高级更改为低级或反之亦然时设置输出流-但我真的很怀疑结果将是您想要的。它也会很慢。
java.util.logging
ConsoleHandler
StreamHandler
publish
由于在Tomcat的生产部署中,无论如何您都不会登录到控制台(默认情况下会登录到文件),因此我建议不要为此担心。