Eclipse Console - what are the rules that make stack traces clickable?

I log quite a bit of stuff, and have noticed that Eclipse Console makes Java stacktraces clickable. The exception is highlighted (goes to the "Create Breakpoint" dialog box) and the filename + numbers are highlighted too (allows going straight to that line).

I was wondering if I could format my normal log lines so the Eclipse Console would do the same to them. A possible approach could be making them look like stack trace lines, but in order to keep as much information as possible I would like to know the exact rule that Eclipse use to detect these lines, but Eclipse 3.6.2 is rather big so it is a herculean task.

The question is then, what are the rules in play here, and where are they defined?



Edit: The logback pattern layout snippet is %msg \(%file:%line\)%n

--------------Solutions-------------

This snippet may help. It can be placed anywhere in your code and will print a "clickable" line on the eclipse console:

StackTraceElement s = Thread.currentThread().getStackTrace()[1];
System.out.printf("%s.%s(%s:%s)%n", s.getClassName(), s.getMethodName(),
s.getFileName(), s.getLineNumber());

Update:

This question has an answer, that may include a solution for your problem:

Eclipse console: detect warning and error patterns and make them clickable



Here we go: we have to contribute an implementation of org.eclipse.ui.console.IPatternMatchListenerDelegate through extension point org.eclipse.ui.console.consolePatternMatchListeners.

The contributions that provide hyperlinks for exceptions and line numbers in stack traces are defined in the org.eclipse.jdt.debug.ui plugin, the implementing classes are in the same bundle.

The rules are regular expressions and can be found in the plugin.xml of the contributing plugin.

If you print (filename:lineNumber), Eclipse will convert it to a link.

Example:

System.out.println("message (Hello.java:2)");

I don't know if there are other rules or where they are defined.

Category:java Time:2011-03-08 Views:1

Related post

  • Eclipse console: detect warning and error patterns and make them clickable 2009-05-25

    I'm running the flex compiler (mxmlc) from ant inside eclipse for some of our builds (they are meant to run on our continuous integration server as well, that is why I don't build using flex builder itself) -- the patterns of mxmlc are not recognized

  • Stack Trace Console in IntelliJ IDEA 2011-10-10

    Does IntelliJ have an equivalent to Eclipse's "Java Stack Trace Console," where you can paste in a stack trace and it will linkify it for you if it matches any of the source files in your project? --------------Solutions------------- ⇧⌘A -> Analyz

  • Colorize logs in eclipse console 2008-10-24

    Is there a way to colorize parts of logs in the eclipse console. I know I could send to error and standard streams and color them differently but I'm more looking someting in the lines of ANSI escape codes (or anyother, HTML ?) where I could embed th

  • PHP: Messaging/Logging to Eclipse Console? 2008-12-17

    Is it possible to send messages from a PHP script to the console in Eclipse? Has anyone attempted this already? I'm not very familiar with how the console works, so I'm not sure if there is a standardized method for communicating with it. -----------

  • How to write a hyperlink to an eclipse console from a plugin 2009-02-26

    I would like to write the location of a file to the eclipse console as a hyperlink. When you click on it it should open the file in eclipse. I'm currently doing something like this (but the link doesn't show up) console = new MessageConsole("myconsol

  • Writing to the Eclipse console 2009-04-06

    My plugin has to write to the eclipse console - for testing purpose I simplified my code, so that I only have the following: public void start(BundleContext context) throws Exception { super.start(context); plugin = this; System.out.println("Tecomp P

  • display chinese character in eclipse console output 2009-06-27

    I am trying to display some Chinese characters in the GB2312 encoding in the eclipse console. I realize that in Run Dialog -> Common tab -> Console Encoding, I can choose additional encodings other than the default CP1252. However, how I can ad

  • Eclipse console in RCP missing output 2009-10-13

    In my RCP I show the Console and want to output different categories of output (not just STDERR and STDOUT). I have looked at and used code from: Writing to the Eclipse console I go through all the actions as prescribed: find or create a console, cre

  • Hyperlinking the eclipse console - delayed writes causing BadLocationException? 2009-12-18

    I'm writing an eclipse plugin with a hyperlinked console, but I see BadLocationExceptions when creating the hyperlinks. To create the hyperlink, I followed the instructions on the related question How to write a hyperlink to an eclipse console from a

  • Servlet post request logging to Eclipse console 2010-01-20

    I'm writing my first Java EE application, using EJBs, Servlet, JSPs and the likes. I'm using JBOSS 4.2 AS and Eclipse as and IDE, including tasks like starting and stopping the server. What I can't understand is that while logging instructions inside

  • How to run ant from an Eclipse plugin, send output to an Eclipse console, and capture the build result (success/failure)? 2010-03-02

    From within an Eclipse plugin, I'd like to run an Ant build script. I also want to display the Ant output to the user, by displaying it in an Eclipse console. Finally, I also want to wait for the Ant build to be finished, and capture the result: did

  • How to output messages to the Eclipse console when developing for Android 2010-06-09

    How can I print messages (like a flag) to the Eclipse console (or log) when developing and debugging an Android app --------------Solutions------------- Rather than trying to output to the console, Log will output to LogCat which you can find in Ecli

  • Why does kbhit() always return 0 when input is entered in the Eclipse console? 2010-07-09

    I am running Eclipse CDT (Helios) for C/C++ on Windows 7 x64. At first I was having the problem of output not appearing when run in the Eclipse console until the program exited, even though it did while running in a Windows console. I discovered this

  • Eclipse Console Error That JAVA_HOME Is Missing 2010-07-23

    In the Eclipse console, I'm getting an error that JAVA HOME is not set. I went ahead and set it to .;C:\Program Files\Java\jre1.6.0_02\ in system variables Then I restarted eclipse, but I keep getting the same error. What am I doing wrong? ----------

  • Log4j output not displayed in Eclipse console 2010-08-17

    For some reason my Eclipse console no longer displays Log4j INFO and DEBUG statements when I run JUnit tests. In terms of code there hasn't been any change, so it must something to do with the Eclipse configuration. All I do in my Unit test is the fo

  • Displaying info in the eclipse console 2010-10-23

    I'm trying to compile a C++ project (Hello World) in windows 7 using Eclipse Helios. After creating the project the console shows me the next message: Internal Builder is used for build ** g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\hello.o ..\src\

  • Garbage in Eclipse console log 2010-11-03

    I have a problem with logs display in my eclipse console. The japanese characters displayed in starting and stopping the weblogic server are garbage. There is no problem however with the logs written by the application. I am using log4j. Log4j.proper

  • Log4j messages lost in Eclipse console when running in Ant 2011-01-07

    I've been trying to get logging with Apache log4j to appear correctly in Eclipse's console when running in Ant and am having no luck. I have a working log4j.xml configuration that has a basic root logger, with a debug priority and a ConsoleAppender.

  • Print unique ascii characters in eclipse console 2011-01-17

    Kind of a strange question but... here it goes. Recently my application threw an IOException that the text only had a clubs symbol in it (like the suit in cards) I know this is probably because there was a number in there that was cast to a char and

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.948 (s). 13 q(s)