Thursday, August 29, 2019

writeDiagnostics in OAF


pagecontext.writeDiagnostics is a combinations two different objects. 

writeDiagnostics  is the simple method in the OAF to show/create log messages and pagecontext is the OAF class object which helps to execute the writeDiagnostics method in the OAF controller.

 to add logging / debug messages in Oracle Application Framework.

to write log / debug statements in Controller (CO), Application Module Implementation class(AM), ViewObject and ViewObject Row Implementation class (VO) and Entity Object Implementation class (EO) in OA Framework.

OA Framework has a method writeDiagnostics() which can be used from anywhere in the above mentioned classes. 

This methods are published by oracle.apps.fnd.framework.webui.OAPageContext and oracle.apps.fnd.framework.server.OADBTransaction (for example, if you want to make logging calls in a UI controller, use OAPageContext. 

If you want to make logging calls from an application module, use OADBTransaction).  Below give are the example to show how to call these methods in different places.

Here below I will explain in detail about pagecontext.writeDiagnostics  in oaf and how we can use this in our OAF Pages.
 

To view log mesages, select the Diagnostics global button from any page (this global button is configured as part of the standard global menu added to each page; the display of this menu item is controlled by the profile option FND: Diagnostics (FND_DIAGNOSTICS)) 

Diagnostics can be enabled at various levels:
  • Show Log - directs you to the Oracle Applications Manager where you can view a "snapshot" of your Oracle E-Business Suite system.
  • Show Log on Screen - allows you to specify a log level and display Java log messages for a particular HTTP Request-Response at the end of the current page. For additional information about this feature, refer to the section titled "Using Logging to Screen" in the Oracle Application Framework Developer's Guide chapter called How to Configure Logging of the Oracle E-Business Suite Supportability Guide, available on the Applications Release 12 Online Documentation CD.
  • Set Trace Level - displays the Set Trace page where you can specify the level of information to collect in a database trace. 
  • Show Pool Monitor - displays the Application Pool Monitor where you view different aspects of runtime and configuration information about the JVM.

Here we are discussing only about the option "Show Log on Screen".

The debug messages can be written in various level:

  • Statement (1)
  • Procedure(2)
  • Event(3)
  • Exception (4)
  • Error (5)
  • Unexpected(6)
Depends on which options you choose, the screen will display all the debug messges written on that level or above. I prefer to write the debug messages at the exception level, so if I select the option Exception(4) in the screen, i can see only my debug messages.(most of the standard logging statements are written at Statement(1) level.)
  • From a Controller
if(pageContext.isLoggingEnabled(OAFwkConstants.EXCEPTION))  
 {  
      pageContext.writeDiagnostics(this,"[TestCO]processRequest():- <Log Message Here!!!!!!>",OAFwkConstants.EXCEPTION);  
 } 

  • From AM Impl class
 if(this.isLoggingEnabled(OAFwkConstants.EXCEPTION))   
 {  
      this.writeDiagnostics(this,"[TestAMImpl]testMethod():- <Log Message Here!!!!!!>",OAFwkConstants.EXCEPTION);  
 }  
  • From VOImpl class
 if(this.isLoggingEnabled(OAFwkConstants.EXCEPTION))   
 {  
      this.writeDiagnostics(this,"[TestVOImpl]testMethod():- <Log Message Here!!!!!!>",OAFwkConstants.EXCEPTION);  
 }  
  • From VORow Impl class
 import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;  
 OAApplicationModuleImpl appModule = (OAApplicationModuleImpl)this.getApplicationModule();  
 if(appModule.isLoggingEnabled(OAFwkConstants.EXCEPTION))   
 {  
      appModule.writeDiagnostics(this,"[TestVORowImpl]testMethod():- <Log Message Here!!!!!!>",OAFwkConstants.EXCEPTION);  
 }  
  • From EOImpl class
 import oracle.apps.fnd.framework.server.OADBTransaction;  
 OADBTransaction transaction = this.getOADBTransaction();  
 if(transaction.isLoggingEnabled(OAFwkConstants.EXCEPTION))   
 {  
      transaction.writeDiagnostics(this,"[TestEOImpl]testMethod():- <Log Message Here!!!!!!>",OAFwkConstants.EXCEPTION);  
 }  
    If you are running from Jdeveloper, you could just use the SOP statements.
     System.out.println("[TestCO]processRequest():- <Error Message Here!!!!!!>");  
    

    This is a custom method which I normally use, which is helpful when you want to change the debug levels. This is used in CO, if you want you can write something similar in AM :)
     public void writeLog(OAPageContext pageContext, String message)   
     {  
          if(pageContext.isLoggingEnabled(OAFwkConstants.EXCEPTION))  
          {  
               pageContext.writeDiagnostics(this,message,OAFwkConstants.EXCEPTION);  
          }  
          System.out.println(message);  
     }  


    Complete Details about pagecontext.writediagnostics in oaf

    writeDiagnostics Method

    writeDiagnostics(Object module ,String message,int logLevel);
    module - current module, usually the "this" pointer
    message - message to be included in the log. Limit 4000 characters.
    logLevel - Type of log message. Valid values are (UNEXPECTED,ERROR, EXCEPTION,EVENT,PROCEDURE,STATEMENT,PERFORMANCE)
    If you are using the pagecontext.writediagnostics to see all the OAF pages log message you first need to set this profile at user level.


    FND: Debug Log Level

    No comments:

    Post a Comment

    AME (Approval Management Engine)

    AME (Approval Management Engine) : AME Stands for Oracle Approval Management Engine. AME is a self service web application that enables...