问题
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