View Logging Information

View Logging Information
calac41
You can get an understanding of what rules fired and what SQL was issued by viewing the logging information. 
CA Live API Creator
 generates logs (for example, rule and SQL execution). You can also generate logs using JavaScript context.
You can use the logs to do the following:
  •  
    View rule execution.
     The log depicts the rules that fire, including complete row state, with indenting to show multi-object chaining.
  •  
    Verify that the SQL that 
    CA Live API Creator
     issued is what you expected.
     
By default, the cached transactions for the last ten authentication tokens are available in the log. If you want to persist your 
CA Live API Creator
 log messages, you can configure external logging.
For more information about how to configure external logging, see External Logging.
In this article:
 
Set up the Log
You set up the log by configuring your authentication token for logging. The log level and the log areas you select control the amount of log information. You can turn logging up and down depending on how much detail you require.
You can also control the logging level with URL parameters.
For more information about how to control the logging level with URL parameters, see URL Parameters.
 
Follow these steps:
  1. With your API open, in the Manage section, click 
    Auth Tokens
    Logging
    .
  2. Define the levels at which 
    CA Live API Creator
     logs messages:
    For general debugging, for database access and rules engine, choose 
    Debug
     as the logging level.
    Values:
     
    • error:
      Serious issues that make 
      CA Live API Creator
       unusable.
    • warning:
      Issues that can negatively impact 
      CA Live API Creator
       performance, but are not fatal.
    • info:
      Logging messages that reflect high-level activity that may be of interest.
    • debug:
      High-level debugging messages.
      This logging level is typically used during development, but not in production.
    • finer:
      Medium-level debugging messages. The 
      finer
       logging level results in more detail, showing each rule that fires and its effect on the row.
      This logging level is typically used during development, but not in production.
    • finest:
      Low-level debugging messages. Use the 
      finest
       logging level for 
      CA Live API Creator
       debug information.
      This logging level is typically used during development, but not in production.
The log is set up.
Understand the Log and Log Entries
The log in the following image reflects a PUT changing a Lineitem Quantity (line 6), which adjusts the orders' amount_total (line 18) which in turn adjusts the customers' balance (line 24):
  log info.png  
Lines 31-37 show the actual update SQLs. The logic engine produces each of these lines as entries.
The adjustment logic is a one-row update, not a SQL select sum.
The entries are formatted as follows:
  • Forward chaining nest-level indentation.
     The indentation depicts the cascade/adjustment forward chaining. You can skip over portions of the log as needed.
  • Reporting domain object.
     The bracketed string identifies the business logic component reporting the log entry, and how it was called. For example, 
    [Purchaseorder[6] ADJUSTED via lineitemsList]
     means:
    • Purchaseorder
       is reporting.
    • Purchaseorder
       was invoked due to an adjustment by way of 
      Lineitem.lineitemsList
       (the class/accessor through which the adjustment is occurring)
    USER means 
    CA Live API Creator
     invoked the logic because of an API user (REST client) update.
  • Message.
     The next string is the message (for example, what logic is being executed).
  • Column Values.
     The column values of the Table are appended to each log entry (including old values where applicable). This information provides significant insight into the why the logic execution produced the result shown. Altered attributes are grouped to the front, to make changes easier to spot.
Salient log messages:
  • Adjust.
    Child adjusting parent. An entry such as 
    Adjusting summed attribute: balance+=50.0000
     signifies that a child is adjusting a parents sum/count. After all the adjustments are complete for a given parent, an indentation displays as API Creator invokes the parent logic (that is, a Forward Chain).
  • Cascade.
    An entry such as 
    cascading to child lineitems
     signifies that a parent is cascading a changed parent reference value to child rows. This is followed by an indentation as API Creator invokes the child logic (that is, a forward chain).
  • Formula.
    An entry such as 
    ==> Formula changes: isReady
     reflects the execution of a formula that changed the derived value.
    A log entry is not made if the value did not change.
  • Action. 
    An entry such as 
    Action(actionClonePurchaseorder) invoking on
     means that an action event is firing.
  • Checking.
     These confirm the phases of logic execution, and frequently are useful in interpreting ensuing entries.
Access the Log and Log Entries
Your GET/PUT/POST/DELETE requests are displayed as log entries in the log area.
Prerequisite:
 The transaction has completed.
Follow these steps:
 
  1. With your API open, in Analyze section, click 
    Logs
    .
    The Logs page appears. The following image shows this page:
    Screen Shot 2017-03-28 at 10.23.52 AM.png  
  2. Expand the 
    Auth tokens & Requests
     section and then complete the following:
    Auth tokens
     
    Shows the active connections for this API. Select a transaction by clicking the authentication token from this list.
    Requests
     
    Displays your GET/PUT/POST/DELETE requests. Select a request from this list.
    Find
     
    Filter the log to only those logging entries you want to display by entering your search string.
The log entries are displayed in the log area. The line numbers are color-coded to reflect the log level. The log information makes up the rest of the line. The > signs denote rule chaining. The entries are displayed in descending order and include the request date and time.
Reveal Logging Detail
You can reveal logging detail, such as full row content, or reveal formatted logging detail.
On the Logs page, in the log area, do the following:
  • To reveal logging detail, such as full row content, click the log's 
    +
     sign.
  • To reveal formatted logging detail, click the gray text.
Clear Transactions for an Auth Token
On the Logs page, select the authentication token for which you want to purge logs and then click 
Purge Selected. 
The authentication token and all requests details are removed. The page reloads.
View a Complex Example
You can view an advanced example of rule execution using the log.
For more information about this example, see Explore Allocation Example.
Output Messages to the Log
You can output messages to the log using the following code snippet:
log.debug('Customer balance is: ' + currentObject.balance);