Copy

Using ADF Logging (ADF Mastery newsletter June 2016)

View this email in your browser

Using ADF Logging

When I review code for ADF projects, I often see poor or inconsistent logging. Sometimes I even don't see any logging at all! I find this strange and inexplicable, because ADF makes it really easy to add good logging to your application without slowing it down. When all your logging is done with the ADF logger, you can set and change the log level at runtime on all environments through Enterprise Manager or by editing the log configuration file. 

Adding a Logger

Every piece of non-trivial Java code in your application should register its own logger like this:
public MyBean {
  private final ADFLogger logger =
      ADFLogger.createADFLogger(MyBean.class);


You need to refer to the class that contains the logger in the create method so that you can tell the loggers apart and configure them individually.

Once you have a logger object, you can use the methods on it to log messages with various log levels. 
 

Choosing a Log Level

In order to ensure that your project uses log levels consistently, your developer handbook/guidelines/wiki needs to set down some rules. I propose the following in my ADF tutorial book:
  • SEVERE for critical errors that your operations staff needs to know about
  • WARNING should indicate misconfigurations, missing data or failures from other components or external systems
  • CONFIG is for information read from property files and configuration databases as well as initialization of classes
  • FINE is information about method calls and should only be used once or twice in a method (when entering and/or when leaving, showing parameters and return values)
  • FINER is detailed logging of steps within a method
  • FINEST is for logging inside loops.

Business Level Logging

I've found that it is a good idea to produce specific logging for business users, and I recommend reserving the INFO level for this. Most logging is very technical and intended for either other developers or operations staff, but the INFO logging should use business terms. For example: "Order 456472 was placed on hold because item Medium Red Widget is not in stock." This allows you to extract these logs and show them to the business to explain why the system works the way it does. 

Do you need a bit of help with your ADF project? I offer ADF Mentoring where you get unlimited access to ask me ADF-related questions by email, phone or web conference. Send me an e-mail to hear more.

Conference Season

I'll shortly be heading to the KSCope16 conference in Chicago. This is a great place to meet all the movers and shakers in the ADF world, so I hope you'll join me. I'll be giving my "Five Ways" tools overview presentation there and moderating a panel discussion on development tools. If you want to talk about ADF, you can find at the ADF sessions in Chicago. 



There is not going to be an ADF Mastery newsletter in July, but I'll be back in August.
Feel free to forward this newsletter to others who might find it useful.
If you have received a copy of this newsletter from someone else and want to subscribe yourself, you can sign up here. For general news about Oracle development tools, sign up for my Oracle Tool Watch newsletter
Copyright © 2016 More Than Code ApS, All rights reserved.


unsubscribe from this list    update subscription preferences