View Logging Information

View Logging Information
lac52
You can get an understanding of the rules that 
CA Live API Creator
 fired and the SQL that 
CA Live API Creator
 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 Add URL Parameters in Requests.
Follow these steps:
 
  1. With your API open, in the Secure 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 might 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. This level results in more detailed messages than the 
      debug
       level, 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 this 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 Tools 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, including a timestamp for the request using your local time zone. 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" = ? ---
View the Error Source from the Call Stack
You can view the source of the error from the call stack in your log. Functions, JavaScript libraries, request/response events, and rules can throw errors. The following code snippet shows an example of an error that a request event throws: 
Exception thrown while executing request event : Internal server error: Error while compiling script : RQ 2007 :
RQ2007-MyReqEvent
:2:3 Expected ( but found req if req.resourceNam =="MyResource" { ^ in RQ2007-MyReqEvent at line number 2 at column number 3
The following table lists the sources of errors that display in the call stack in your logs and the format in which they display:
Source
Format
Functions
FU###-[Function Name]
JavaScript libraries
LI###-[Library Name]
Request/response events
RQ###-[Request/response event name]
Rules
RU###-[Rule Name]
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);