Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-dev] Using output file:linenumber: links?

> log4j.appender.myConsole.layout.ConversionPattern=%5p - %m - %l%n
...
>    something.something(something.java:number)<end of line>
...

This doesn't work alone. What exactly are the requirements so that a real 
hyperlink is created? I got it working with log4j, but now that I am 
trying my own code (at the end of this message), I just can't get it to 
work.


I had to add my source path to the Run


public void log( int level, String msg )
{
	if( level < log_level )
	{
		return;
	}
	Throwable t = new Throwable();
	StackTraceElement[] stackElements = t.getStackTrace();
	if( stackElements.length > 2 )
	{	
		// class.method(file:line)
		StackTraceElement ste = stackElements[2];
		System.out.println(
			msg
			+ " - " + ste.getClassName()
			+ "." + ste.getMethodName()
			+ "(" + ste.getFileName()
			+ ":" + ste.getLineNumber()
			+ ")"
		);
	}
}


-- 
timo




Back to the top