Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Grab Eclipse Console Output Painlessly

DZone's Guide to

How to Grab Eclipse Console Output Painlessly

· Java Zone ·
Free Resource

Get the Edge with a Professional Java IDE. 30-day free trial.

In your plugin, if you want to do something with each line of your eclipse output console, for example write that line to a file, or parsing it before sending it to your custom eclipse view, you should create a class which implements IConsoleLineTracker, and you should add this extension point to your plugin.xml.

[img_assist|nid=1032|title=|desc=The steps are explained well here...|link=none|align=none|width=256|height=192]

Now, suppose your class implementing IConsoleLineTracker is this:

public class LogTracker implements IConsoleLineTracker {

private IConsole m_console;

public void dispose() {

}

public void init(IConsole console) {
m_console = console;
}

public void lineAppended(IRegion region) {
try {
String line = m_console.getDocument().get(region.getOffset(), region.getLength());

// DO SOMETHING WITH THAT LINE
} catch (BadLocationException e) {
WrCheck.logError(e);
}
}
}

Get the Java IDE that understands code & makes developing enjoyable. Level up your code with IntelliJ IDEA. Download the free trial.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}