View Logging Information

View Logging Information
lac42
CA Live API Creator
 generates logs, for example, when it fires rules firing and when it executes SQL. You can also have 
CA Live API Creator
generate logs using JavaScript context. You can view rule execution and you can verify that the SQL that 
CA Live API Creator
 issued is what you expected using these logs. The log includes row state, with indenting to show multi-table transaction logic.
By default, the log includes the cached transactions for the last ten authentication tokens. 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
    , and then click 
    Logging
    .
  2. Define the levels at which 
    CA Live API Creator
     logs messages (from highest to lowest).
    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.
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 the Analyze section, click
    Logs
    .
    The Logs page appears. The
    Auth tokens & Requests
    section is expanded by default.
  2. Complete the following fields:
    Auth tokens
    Shows the active connections for this API. Select a transaction by clicking the authentication token from this list. You can enter filtering criteria.
    Requests
    Displays your GET/PUT/POST/DELETE requests. Select a request from this list. You can enter filtering criteria.
    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 greater than symbols (>) 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.
Understand the Log and Log Entries
The log in the following image reflects a PUT changing a Lineitem Quantity (line 18) for the Demo API example, which adjusts the orders' amount_total (line 29) which in turn adjusts the customers' balance (line 40):
LogMetrics1.png
Lines 47-52 show the actual update SQLs. The logic engine produces each of these lines as entries.
LogMetrics2.png
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.
     
    CA Live API Creator
     appends the column values of the table to each log entry (including old values where applicable). This information provides insight into the why the logic execution produced the result that is shown.
    CA Live API Creator
     groups altered attributes to the front.
Salient log messages:
  • Adjust.
     Child adjusting parent. An entry such as 
    Adjusting summed attribute: balance+=50.0000
     signifies that a child is adjusting a parent's 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 entry is followed by an indentation as 
    CA Live 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 entries confirm the phases of logic execution, and frequently are useful in interpreting ensuing entries.
View SQL Query Execution Time
You can view the queries to a SQL database for your API and the SQL execution time (in ms). For example, line 48 of the previous log entry shows the first update SQL execution and the execution time:
SQL:
0.459454ms
default demo qtp1789447862-15 update "DEMO"."PurchaseOrder" set "amount_total" = ? where "order_number" = ? ---
Clear Transactions for an Authentication Token
On the Logs page, select the authentication token for which you want to clear transactions, and then click 
Purge Selected. 
The authentication token and the request details are removed. The page reloads.
View a Complex Example
The Explore Allocation example is an advanced example that illustrates rule execution using the log.
For more information about this example, see 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);