Pages

Thursday, March 6, 2014

ADF Logging Explained Chapter 1

Logging in ADF Application


This post talks about using ADFLogger in adf application. The ADFLogger is a logging mechanism which is built into the ADF framework. It is built on top of java.util.logging API.

Using ADFLogger :

To start with you need to define the ADFLogger instance in your class ... something like below code :


public class TestLoggerTFBean {
    public TestLoggerTFBean() {
        super();
    }
    private static  ADFLogger logger = ADFLogger.createADFLogger(TestLoggerTFBean.class);

There are additional methods available in ADFLogger API to create ADFLogger instance. For other methods please refer to ADFLogger JAVA API.

Where to View Available Loggers :

Run your integratedWeblogic server and choose "Configure Oracle Diagnostic Loggin" from Actions. You will able to see all available loggers in the logging.xml file.


Registering your ADFLogger :

You can register your logger by clicking green plus "+" icon in right on logging.xml. You can choose to add transient (discarded at the end of session ) logger or persistent (stored in logging.xml) logger.

OR

When you run your application, you might notice that logger gets registered as when it is initialised.
 
In the sample app provided, there are two taskflows : 1) noLogger-tf 2)testLogger-tf . An ADFLogger instance in created in pageFlowScope managed bean for testLogger-tf. Running the TestLoggerPage.jspx loads the noLogger-tf ( Not ADFLogger instance created yet ). If you notice registered loggers, our custom logger "TestLoggerBean " is still not registered.
 
Click the button to navigate to testLogger-tf taskflow. Click button "Do Some Logging" to log something. Now again check available loggers and our custom logger is available.