Skip to content

Application Logger

The Application Logger is a Utility class which can be used store log information for the duration of a single Client to DB call. The log information is stored in database session for the duration of the call, and then should be returned back to the client or stored in a table. This logger is independent from other Tracing or Logging functionalities such as Log_SYS or Trace_SYS. The Application Logger utilizes the App_Context_API to store information.

API Information

The PL/SQL package Application_Logger_API contains the API methods for the functionality.

Log Information Categories

  • INFORMATION
  • WARNING
  • ERROR

API Methods

Log

Used to Log Information

PROCEDURE Log (  
   application_name_     IN VARCHAR2,  
   category_             IN VARCHAR2,  
   in_text_              IN VARCHAR2,  
   indent_on_call_depth_ IN BOOLEAN DEFAULT FALSE,  
   indent_offset_        IN BINARY_INTEGER DEFAULT 3)
Parameter Description
application_name_ Unique name identifying the application or functionality generating the log
category_ The type of Log information (INFORMATION, WARNING, ERROR)
in_text_ The Log information
indent_on_call_depth_ Specify TRUE if you need the Log information to be indented based on the Call Depth. (I.e. the deeper the call to the method, the more indented the Log information becomes)
indent_offset_ When indent_on_call_depth_ is set to TRUE, this can be used to offset the depth. Enter a positive value to decrease the indentation, a negative value to increase it.

Get_All

Collect all Log information from Application Context, format and return using output_ parameter. Also clear the related log information from Application Context. Setting mark_XXX_ parameters annotates the related log information. If this Log information is to be displayed, then setting the appropriate mark_XXX_ makes it easier to format the log information (i.e. highlight errors) in a better way.

PROCEDURE Get_All (  
   output_           IN OUT NOCOPY CLOB,  
   application_name_ IN VARCHAR2,  
   mark_info_        IN BOOLEAN DEFAULT FALSE,  
   mark_warning_     IN BOOLEAN DEFAULT FALSE,  
   mark_error_       IN BOOLEAN DEFAULT FALSE)  

Parameter Description
output_ Log information
application_name_ Unique name identifying the application or functionality generating the log
mark_info_ Annotate information messages as <INFO>message </INFO>
mark_warning_ Annotate Warning information messages as <WARNING>message </WARNING>
mark_error_ Annotate Error information messages as <ERROR>message </ERROR>

How to Use

The App Logger Utility can be used directly, but the easiest way to use is to create a wrapper PL/SQL package, which can be then used in the code.

Following is an example Logger class created using the Application_Logger_API, the Logger's PL/SQL package is My_App_Logger_API.

Then this API can be used in the functionality which needs the logging. It can be used in multiple PL/SQL packages.

A sample PL/SQL package is given below.

Calling the Do_Import method will return in the following Log information.