问题
We all mostly use System.out.println in the Console of our IDE. I am using Eclipse. I can also clearly see the println() message on my Mac's Console app. Which is nice for my personal things.
And here is the code:
public class Main {
public static void main(String[] args) {
System.out.println("Is this logged anywhere?");
}
}
And here's what I see on my Mac:
Does Windows have something similar to the Mac's version of Console?
回答1:
Sadly, as previously said, we don't really have that on Windows. Your best options is to run your program from CMD and then pipe the standard out to a file. Something like java -jar HelloWorld.jar > hello.txt.
What I usually do is create a Handler to a log file (usually just [program name] log [date].txt and have all messages outputted there depending on the log level, which is good practice if you're used to only using System out prints.
Straightforward answer remains that no such functionality comes standard with Windows. You'll have to pipe to a file in some manner.
回答2:
It does not. However you can simply run the process from a command prompt if you want to examine its stdout. (As you said, eclipse works too, of course.)
来源:https://stackoverflow.com/questions/14544690/java-mac-windows-with-system-out-println