如何使用日志记录捕获 netbeans 中的本地事件

how to capture natives events in netbeans using logging

http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/doc-files/logging.html

public static void main(String[] args) {
    ResourceBundle rb = ResourceBundle.getBundle("your.package.Log");
    int sum = 0;
    for (int i = 0; i < 10; i++) {        
        LogRecord r = new LogRecord(Level.INFO, "MSG_Add");
        r.setResourceBundle(rb);
        r.setParameters(new Object[] { sum, i });
        Logger.global.log(r);
        sum += i;
    }        
    LogRecord r = new LogRecord(Level.INFO, "MSG_Result");
    r.setResourceBundle(rb);
    r.setParameters(new Object[] { sum });
    Logger.global.log(r);
} 

Logger.global 已弃用。如果将记录器行更改为(显然将 <YOUR CLASS> 更改为 class 的名称)

Logger.getLogger(<YOUR CLASS>.class.getName()).log(r);

然后记录的行将出现在 NetBeans 的“输出”选项卡中