简体   繁体   English

我可以在Netbeans 7.3中获得“更好”的详细输出吗?

[英]Can I get a 'better' verbose output in Netbeans 7.3?

I'm trying to find an output mode that will show me the execution and order of every method called in the running program. 我试图找到一种输出模式,该模式将向我显示正在运行的程序中调用的每个方法的执行和顺序。 Verbose and debugger output detail don't seem to give me that. 详细的和调试器的输出细节似乎没有给我那样的信息。 Is there any way to get a detailed output like the one I've described here? 有没有办法像我在这里描述的那样获得详细的输出? Thanks! 谢谢!

You can do something like this using the following ways: 您可以使用以下方式执行以下操作:

One : Put either of these codes in every method in your program: 一个 :将这些代码之一放入程序的每个方法中:

System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
System.out.println(new Object(){}.getClass().getEnclosingMethod().getName()); 

Two : Use the dumpStack() method: :使用dumpStack()方法:

Thread.currentThread().dumpStack();

Three : Use the printStackTrace of Throwable :使用ThrowableprintStackTrace

new Throwable().printStackTrace();

Four : This is a variation of the first solution :这是第一个解决方案的变体

StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
for(StackTraceElement st : stackTrace){
    System.err.println(st);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM