java - Eclipse 插件日志不会立即打印在 swt 按钮 onclick 事件的控制台中

标签 java eclipse plugins

为了打印我使用的控制台中的日志

MessageConsole console = new MessageConsole("System Output", null); 
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });             ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
MessageConsoleStream stream = console.newMessageStream();
System.setOut(new PrintStream(stream));
System.setErr(new PrintStream(stream));

String rootPath="D:/luna/sampleproject";
System.setProperty("file.log",rootPath+"logs/log_console.log");

正确打印日志 我的问题是它不会立即打印 swt onclick 事件中的日志。它打印日志所有过程已完成。

我的示例代码是:

button_Ok.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            log.info("Before invoking the api call");
            CreateDesign create=new CreateDesign();
            boolean status=create.createDesign();//api invoked
            log.info("Api invokoing is completed...");
        }

}

这里是整个api调用过程完成后打印的日志消息。

如何立即打印执行日志?

最佳答案

尝试使用

new PrintStream(stream, true)

用于 PrintStream 构造函数更快地刷新流。

关于java - Eclipse 插件日志不会立即打印在 swt 按钮 onclick 事件的控制台中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37435191/

相关文章:

Java通过方法设置变量

java - 安装和试用 jesque-web

java - 如何获取给定函数的调用路径?

asp.net-mvc - asp.net mvc中是否有像drupal这样的cms系统

wordpress - WooCommerce 结账

C# 插件,是 Assembly.LoadFrom()... 类慢吗?

java - fragment 中的字节数组参数为空

java - 您可以使用 session.execute 从 Datastax 驱动程序执行创建表吗?

java - @SuppressWarnings 用于最终类型参数

java - 在 servlet 中使用 PDFParser 时未找到类定义。但在Java应用程序中工作