Search Results


Wednesday, April 15, 2009

Logging in Apps

How to do logging in the OAF controller?

You can do logging in OAF page using following statement
pageContext.writeDiagnostics(this,"building is :"+s_building,OAFwkConstants.STATEMENT);

Syntax:
void writeDiagnostics(Object module,
String messageText,
int logLevel)

Writes an entry to the diagnostics log according to a specific log level.

Parameters:
module - current module, usually the "this" pointer
messageText - message to be included in the log. Limit 4000 characters.
logLevel - category or type of log message. Valid values are are from OAFwkConstants. (UNEXPECTED, ERROR, EXCEPTION, EVENT, PROCEDURE, STATEMENT, PERFORMANCE)


How to do logging in the bc4j objects?

The pagecontext won't be available for Application module, View Object Impl and Entity object Impl. So in this case, you can use OADBTransactionImpl.writeDiagnostics to log your messages.

oracle.apps.fnd.framework.server.OADBTransactionImpl

Syntax:
public void writeDiagnostics(Object module,
String messageText,
int logLevel)

Writes an entry to the diagnostics log according to a specific log level.

Parameters:
module - current module, usually the "this" pointer
messageText - message to be included in the log. Limit 4000 characters.
logLevel - category or type of log message. Valid values are are from OAFwkConstants. (UNEXPECTED, ERROR, EXCEPTION, EVENT, PROCEDURE, STATEMENT, PERFORMANCE)


Eg:
if (OADBTranasctionImpl.isLoggingEnabled(OAFwkConstants.PROCEDURE)) {
OADBTransactionImpl.writeDiagnostics(this, "your message", AFwkConstants.PROCEDURE);
}


How to see the log?

You can see the output in the OAF Screen itself.
1. Select Diagnostics button from any page
2. In the Diagnostics page select Show Log on Screen option.

Now you will be able to see the application log appened to the bottom of the page.



How to debug pl/sql program?

The standard way to debug the plsql code is using fnd_log package.
set the following profile options to enable log.

FND: Debug Log Module = '%'
Enables log for all modules

FND: Debug Log Enabled = 'Yes'
Enables the logging

FND: Debug Log Level = 1
This will log all the statement level log messages.


You can use the following procedure to log the messages in pl/sql, forms or reports.

--Get the log enabled profile option
g_fnd_debug CONSTANT VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
--Check if the log is enabled
IF (g_fnd_debug = 'Y') THEN
--Check if the log level is less than procedure level
IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_PROCEDURE) THEN
--Log the message
FND_LOG.string(FND_LOG.LEVEL_PROCEDURE, g_module_prefix || l_api_name ||'.invoked', 'Log text');
END IF;
END IF;


How to see the pl/sql debug log?

All the FND_LOG.string messages would be logged in the fnd_log_messages table ordered by log_sequence column.

1. Note the sequence number before running the procedure
select max(log_sequence) from fnd_log_messages;

2. Run your pl/sql program

3. Now run the following query to see the log messages.
select count(*) from fnd_log_messages where log_sequence BETWEEN 1925713 and 1929506;



Article By:
Prasanna Jayaraman

Please post your Ideas and Comments
Post a Comment