Logging is an important in debugging and tracing the issue.In Adf framework we have ADF logger.
How to use it ADF logger in ADF application.Hopefully , after reading you will have a good idea on it.
Q) How to Turn On Diagnostic Logging
To turn on diagnostic logging, set the Java system property named
jbo.debugoutput to the value console. Additionally, the value ADFLogger lets
you route diagnostics through the standard Logger implementation, which can be
controlled in a standard way through the logging.xml file
Inside JDeveloper is to edit your project properties and in the Run/Debug page, select a run
configuration and click Edit. Then add the string -Djbo.debugoutput=console to
the Java Options field.
Q)How to locate the logging.xml
There are following two ways to get to the logging configuration screen.
1. Open the Application Server Navigator (Ctrl + Shift + G), right mouse click on the IntegratedWeblogicServer and select Configure Oracle Diagnostic Logging for “IntegratedWeblogicServer”.
2. From the Log window (usually docked underneath your editor) pull down the Actions menu and select Configure Oracle diagnostic Logging.
How to configure log level–
we need to set the log Level to at least FINE. Let’s set it to the most detailed level FINEST – TRACE:32 or anything you want to set ,if using ODL Log Levels – for the oracle.jbo logger.
If you are using Integrated WebLogic Server in JDeveloper on the Windows platform,
you can find the logging.xml file in a location similar to:
C:\Documents and Settings\username\ApplicationData\JDeveloper\latest_system_folder\DefaultDomain\config\fmwconfig\servers\DefaultServer The log files for Integrated WebLogic Server are in a location similar to:
C:\Documents and Settings\username\ApplicationData\JDeveloper\latest_system_folder\DefaultDomain\servers\DefaultServer\logs
The log files for a standalone WebLogic Server instance are in a location similar to:
$domain_home/servers/your_servername/logs
In the Project Properties dialog, click the Run/Debug/Profile node and create a
new run configuration.. In the Run Configurations list, double-click the new run configuration to edit its
properties.4. In the Edit Run Configuration dialog, for Launch Settings, enter the following
Java options for the default virtual machine:
-Djbo.debugoutput=adflogger -Djbo.adflogger.level=FINE
Set the level=FINE for detailed diagnostic messages
With this the setup is completed. Now open the file (AM, bean or any java class) which belongs to above package and add log messages as shown in below sample file.
You need to set logging in your java classes as below this.
private static final ADFLogger logger= ADFLogger.createADFLogger("Implementation class vinay.class");
createADFLogger() function will create the logger instance .
After initializing the logger, you can use logging within the method as
private static ADFLogger log= ADFLogger.createADFLogger(GammaAMImpl.class);
For debug messages in try block/ normal debug messages , write
if(log.isFine()){ log.fine(String classname,String methodname,String message); }
One important thing ,you need to include the package directory of the implementation project in Logging.xml for adfLogger.
I have used a lot log4j in my jee application.Then why I should use ADF logger compare to log4j.I found view of some adf expert on internet .So sharing with you all. Not sure about all the points:-
Pros to use ADFLogger:
– You can control trace level in Oracle Fusion Middleware Console (Enterprise Manager) with a visual interface.
– You have support by Oracle if you are having problems with logging solution.
– You have an ADFLogger for JavaScript too.
– Have more trace level’s than log4j.
Cons to use ADFLogger:
– You need to associate ADF libraries to your PDK’s.
Pros to use log4j:
– Best known for most developers.
– Easy to set different log strategies and file sizes.
– Goog performance.
– Easy to extend and use Wrappers with it.
Cons to use log4j:
– You can’t control trace level with visual interface provided by Oracle. You need to change manually log4j.properties
– You haven’t Oracle Support for log4j.
It’s only my own opinion. To me is recommended to use ADFLogger if you are in ADF Application. If you are in a JSR-168 or another application use log4j instead of ADFLogger.