Tomcat STDOUT as Error in Eclipse

前端 未结 5 1919
栀梦
栀梦 2021-02-07 00:11

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 S

相关标签:
5条回答
  • 2021-02-07 00:53

    Yep, the java.util.logging.ConsoleHandler publishes to System.err (and not to the System.out)...

    A workaround that does not involve coding, or just masking any possible error in black is to add to the VM arguments in the eclipse launch configuration:

     -Djava.util.logging.config.file="${workspace_loc}\Servers\Tomcat v8.5 Server at localhost-config\logging.properties"
    

    (adjust the server config folder accordingly)

    and create the logging.properties with:

    .level=WARNING
    

    This way only problems or potential problems will show in the console, but in red, the fitting color.

    0 讨论(0)
  • 2021-02-07 00:55

    The following has worked for me.

    In the Tomcat server.xml, comment out

    <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
    

    Seems like the "red is caused" by Tomcat not be able to load the APR native lib. Skip the loading and no more red.

    0 讨论(0)
  • 2021-02-07 01:02

    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.

    0 讨论(0)
  • 2021-02-07 01:06

    There is a short answer to your question :

    Right clic in Console view > Preferences...

    and then set "Standard Error text color" to black.

    But of course, it would be better if Eclipse knew that Tomcat server log is not to be shown in red.

    It looks like there are no better answers for now : http://www.eclipse.org/forums/index.php?t=msg&goto=531848&

    The problem can be reproduced with Tomcat 6 and Tomcat 7 in Eclipse 3.6.2

    0 讨论(0)
  • 2021-02-07 01:07

    For me it was some other error. It helped, when I made sure, no errors (only infos) where in the start up log. Apparently tomcat switches to error output if it encounters an error.

    0 讨论(0)
提交回复
热议问题