Where do messages sent to System.err go when using Tomcat externally to run a web app from IntelliJ?

无人久伴 提交于 2020-01-06 05:26:40

问题


I am using IntelliJ 2019.3 Ultimate edition IDE to run my Vaadin web app through Apache Tomcat web container.

When a message goes out to System.err such as:

System.err.println( "My message goes here." ) ;

…where does that message land?

On the console displayed within IntelliJ I see message appear that I sent to System.out. But message sent to System.err fail to appear on that same console.


回答1:


Check that console again

The messages should indeed appear in the same console within IntelliJ.

You may not have noticed for a couple of reasons: color, and order.

Colorized

Beware of coloring. Given that the err in System.err means “error”, IntelliJ colorizes such messages as red ink.

Vaadin generates much text in various colors. Your eye may be skipping over those colored blocks, looking for other colors (such as white ink on black background in in dark mode).

Click to zoom the screenshot below created by this code:

System.out.println( "BASIL sout - " + message );
System.err.println( "BASIL System.err message" );

Notice lines 3 & 5.

  • Line 3 in red is from call to System.err.
  • Line 5 in white is from call to System.out.

(Line 4 is from a call made to the Simple implementation of SLF4 logging framework, and is irrelevant here.)

Out-of-order appearance

You may not have noticed your messages for another reason: They may arrive in the console in a different order than you called in your Java code.

See again in that screenshot above. Those lines 3 & 5 arrived out-of-order: Our second call in Java appeared first in the console output (I don’t know why).



来源:https://stackoverflow.com/questions/59132401/where-do-messages-sent-to-system-err-go-when-using-tomcat-externally-to-run-a-we

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