Profilers are great if you have one. Eclipse and Java have some great abilities right out of the box that you can provide your end users and other developers with some performance numbers. Many times the finger may be pointed at your code as a bottle neck and the first thing you do is turn up logging to FINER to get any logger.entering and logger.exiting calls to log to the log file or console.
The main problem with this approach is if you use the same logger throughout your code it will be flooded with all sorts of “other” information that is at the FINER level or greater. Meaning, it may be very hard to tell where the enters and exits line up.
One simple trick is to have each plug-in or package implement a profile logger and use that logger for all of your “enters” and “exits”. This way, from the OSGI console you can just bump up that specific logger to FINER and you will only get method enter and exits logged – with no other clutter.
For example, your normal logger may be:
While your profile logger may be:
The OSGI console command to turn the logging up for your profile logger would be:
setlogrlev com.mycompany.component.profile FINER