Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

nice Code Template for log statements

Jan VerveckenNov 24 2006 — edited Nov 24 2006
hi

I often find myself adding "print debug statements" to my code like this:
public class SomeClass
{
	public void someMethod()
	{
		System.out.println("SomeClass.someMethod() : some info");
	}
}
I already used the default "sop" code template to help me with that.
Now I have been able to configure my own code template that also adds the class name and method name automatically.

I don't know how to export code templates so I'll try to describe it:
In the "Preferences" dialog on the "Code Editor > Code Templates" pane I added a Shortcut "sopl" with Description "System.out.println logging".
On the "Code" tab I added:
System.out.println("$myCurClass$.$myCurMethod$() : " + $end$);
On the "Variables" tab I configured:
Name="myCurClass", Type="curClass", Default Value="x", Editable=<unchecked>
Name="myCurMethod", Type="curMethod", Default Value="x", Editable=<unchecked>

So, if I type "sopl" in my Java code followed by Ctrl+Enter I can add my log statements faster.

I'll probably configure some similar code templates for using Log4J and such.

Maybe someone else finds this usefull.

(using JDeveloper version 10.1.3.1.0.3984)

regards
Jan Vervecken
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 22 2006
Added on Nov 24 2006
1 comment
795 views