Showing posts with label Logging. Show all posts
Showing posts with label Logging. Show all posts

Tuesday, March 13, 2012

JDeveloper: Code Template to show current class and method

For debugging purposes, I sometimes use a simple System.out.println statement to have some values displayed on the console. It's not the best or cleanest way, I know, but it works and is a lot faster than setting up a logging framework first. If you already have a logging framework configured, you might as well use that one, of course. Following method could also be used for quickly generating logging statements.

To keep an overview of the messages printed, I usually preceed every message with currentClass.currentMethod. In JDeveloper, there's an easy way to do this:

  • Open Tools -> Preferences...
  • Go to Code Editor -> Code Templates
  • Add a new one
  • Enter a shortcut (I use 'sopl'), and change the context to Java
  • In the code section, type System.out.println("$myCurClass$.$myCurMethod$(): $end$");
  • In the variables tab, map myCurClass to 'Class Name' and  myCurMethod to 'Method Name'
  • Leave end mapped to 'End Location'
Now you can use sopl in every Java class! Just type sopl and hit Ctrl+Enter.

Thursday, March 8, 2012

ADF Logging

Most people use Log4J for their logging. There are a few others, like Commons Logging, SLF4J, or the default Java Logging API. But if you're working with Oracle's Application Development Framework, there is another option as well: ADF Logging.

ADF Logging is a logging mechanism, embedded in the ADF framework. It wraps the Java Logging API, but throws in a few extra methods and some JDeveloper and (Weblogic) Enterprise Manager features.

A thorough guide on how to use it can be found on Duncan Mill's blog. A 15 minute introduction presentation is also available.