Saturday, December 26, 2009

FAQ #6 - How to fine tune ADF diagnostics logging in JDeveloper 11g R1

Introduction

FAQ #2 – How to enable debug information generation for an ADF BC project demonstrated a simple rather known technique to generate diagnostics logging in the JDeveloper Log window when testing an ADF BC application module with the BC tester. This barely scratched the surface of what is actually available in JDeveloper concerning diagnostics logging.

Main Theme

ADF diagnostics logging is controlled via the usage of the jbo.debugoutput parameter. Using this parameter with the console value, i.e. -Djbo.debugoutput=console, produces diagnostic logs directly in the JDeveloper Log window. When set to the ADFLogger value, diagnostics are routed through the standard J2SE Logging API and is controlled through the logging.xml configuration file. For the integrated WebLogic server this file can be found the C:\Users\username\AppData\Roaming\JDeveloper\ system11.1.1.x.x.x.x\DefaultDomain\config\fmwconfig\servers\DefaultServer for Windows 7 and in the C:\Documents and Settings\username \ApplicationData\JDeveloper\system11.1.1.x.x.x.x \DefaultDomain\config\fmwconfig\servers\DefaultServer for older Windows versions.

Let’s take a closer look:

In the Application Server Navigator – use View | Application Server Navigator to display if needed – expand the Application Servers node and right-click on the IntegratedWebLogicServer connection. This connection is generated automatically by JDeveloper for accessing the integrated WebLogic server. From the context menu select Configure Oracle Diagnostic Logging for “IntegratedWebLogicServer”.



JDeveloper opens the logging.xml diagnostics logging configuration file and displays it in the Overview tab. In the Loggers section expand the Root Logger (default) node to display all the loggers that are declared.



The three columns in the Overview tab display the Name of the logger, the diagnostics logging Level for the logger and any log handlers associated with the logger. The Name of the logger represents the Java package that will be generating the specific diagnostics logs. The Level value specifies the granularity of the diagnostic logs to be generated and it is defined either in terms of the ODL (Oracle Diagnostics Logging) Log Levels below



or as any of the Java Log Levels below



You can control the Log Level type (ODL or Java) through the drop down on the top right just above the Declares Handles column.

The Declares Handles column associates one or more log handlers to the specific logger. To illustrate, select a logger that has an associated log handler - an icon in the Declares Handles column - and expand the Handler Declarations section to display the associated log handlers.



The definition of the loggers in the Overview tab is hierarchical and is derived from top-down. For example: a logger that is specified at the oracle package level, applies to all other loggers below in the same hierarchy (oracle.*) unless it is overwritten.

All of this information and more is accessible in the Structure window. Let’s expand the logging_information node and then the log_handler node and let’s take a closer look at two of those log handlers:



 console-handler
This handler will log diagnostics to the console. Observe that the level attribute is set to ALL. This will allow the hander to log diagnostic messages for all log levels.

odl-handler
This handler will log ODL diagnostics to a log file. Expand the odl-handler log_handler node and observe the path property. It points to the location of the log file where the diagnostic logs will be saved. It is set to ${domain.home}/servers/${weblogic.Name}/logs/${weblogic.Name}-diagnostic.log, which is the C:\Users\username\AppData\Roaming\JDeveloper\system11.1.1.2.*.*.*\DefaultDomain\servers\DefaultServer\logs\ DefaultServer-diagnostic.log file in Windows 7.



OK. Let's generate some diagnostics now. Select the oracle.jbo logger in the Loggers tree and set its Level to FINEST – you may need to switch the log type to Java Log Types. This will override the default setting of the Root Logger in order to log all diagnostics generated by the oracle.jbo classes. There is no need to declare a specific handler, the one(s) defined for the Root Logger will be used as long as we ensure that the Use Parent Handlers checkbox remains selected. Make sure that you save the logging.xml file.



Before running your application open the ViewController Project Properties dialog, select the Run/Debug/Profile page and Edit… the Run Configuration. In the Edit Default Configuration dialog Launch Settings enter -Djbo.debugoutput=adflogger -Djbo.adflogger.level=FINEST in the Java Options.



Save the Project Properties and run your application. Observe the oracle.jbo diagnostic logs generated in the Log window. The same log entries are written in the C:\Users\username\AppData\Roaming\JDeveloper\system11.1.1.2.*.*.*\DefaultDomain\servers\DefaultServer\logs\ DefaultServer-diagnostic.log file as well.




Conclusion

ADF Diagnostics Logging is a powerful feature in JDeveloper. Through simple configuration, it allows you to fine tune the log generation of your application and much more.

Until the next time, keep on JDeveloping!

Code

http://jdeveloperfaq.googlecode.com/files/JDeveloperFAQNo6.rar










1 comment:

  1. Hi,

    Thanks for the post. I have a question in the above example. Why do we need to add -Djbo.adflogger.level=FINEST in the Java Options, when you have already marked level as FINEST for oracle.jbo logger ? Won't setting the java options make all loggers level FINEST ?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...