Pages

Tuesday, March 18, 2014

ADF Logging Explained Chapter 4

ADF Logging Explained Chapter 4

In this post, we tried to cover the commonly used methods of ADFLogger class.

Now I create ADFLogger instance and try to log a message using belowCode : 

private static ADFLogger logger = ADFLogger.createADFLogger(TestLoggerTFBean.class);
logger.log("Logging Message1");

After running the application, I set the LogLevel of my custom ADFLogger to Warning. Now lets see the logged message ...it's not there. Why ? We created ADFLogger instance... logged the message ... set the LogLevel ... and no message Logged. 

Almost all logging methods internally does a check isLoggable before logging. The above logger.log method checks isLoggable(ADFLoggerLevel.TRACE) and which return false because our custom ADFLogger's LogLevel is Warning. 

Lesson Learnt : Information about internal LogLevel check is required before using any log method.

Well not to worry... other log methods are straight forward. Here are some examples : 

logger.severe(String msg)  - This checks isLoggable against Level.Severe.
logger.fine(String msg)  - This checks isLoggable against Level.Fine.
logger.log(Level level, String msg) - This check isLoggable against inputParameter level before logging.


That's it. Enjoy logging.

If you want more than this, please go Adventures in Logging index by Duncan Mills.