如何阅读eclipse控制台日志?

问题描述:

当任何应用程序运行时,我们可以在eclipse控制台中看到日志,例如启动浏览器等。我只是想阅读它。请提供任何示例代码以阅读Java中的这些控制台日志。如何阅读eclipse控制台日志?

+1

你想通过代码阅读?它只是系统输出/ err以及由eclipse用户配置的任何重定向的日志文件。 – yair 2011-12-22 06:42:15

您可以试试IConsoleLineTracker。这是一个example的实现。

我真的不知道这是你要求的东西,但会记录控制台文件和阅读它没问题?

记录到文件中可以做的:

运行/调试设置 - >通用 - (在同一时间它甚至 写能安慰和文件)>标准输入和输出。

然后它只是在Java中的基本文件处理。这是你在找什么?

+0

我想在代码中阅读它,以便我可以更好地格式化它 – Sandy 2011-12-22 07:07:47

如果我没有错,您正尝试读取Eclipse控制台日志。如果是这样,那么我可以向你保证,你可以做到这一点。不,只有这样,你也可以在Eclipse Console中编写一些东西。如果控制台在清一色

private static MessageConsole findConsole(String name) { 
ConsolePlugin plugin = ConsolePlugin.getDefault(); 
IConsoleManager conMan = plugin.getConsoleManager(); 
IConsole[] existing = conMan.getConsoles(); 
for (int i = 0; i < existing.length; i++) 
if (name.equals(existing[i].getName())) 
    return (MessageConsole) existing[i]; 
} 

存在

首先搜索,如果它存在,然后运行下面的代码

MessageConsole myConsole = findConsole("CVS"); // calls the above method 
if(myConsole!=null){ 
IDocument doc = myConsole.getDocument(); 
inputData = doc.get(); 
if (inputData != null) 
      inputData = inputData.trim(); 
if (inputData != null && !inputData.equals("")) { 
//Sysout here the inputData or store in some file 
} 
} 

如需更多信息,请访问这个链接。这是有帮助的 - http://javacodingtutorial.blogspot.com/2013/10/how-to-create-plug-in-that-reads-any.html