Decision Management (ODM,ADS)

 View Only
Expand all | Collapse all

print statement is not logging in the standard output console

  • 1.  print statement is not logging in the standard output console

    Posted Wed August 04, 2021 02:34 PM
    Edited by Satish Kumar Thu August 05, 2021 03:15 PM
    I'm using the ODM version 8.10.5 Decision Service rules (REST) and recently migrated from 8.9.0 classic rules with MDB. 

    then
    print the name of this rule ;
    print "Print the rule name";

    When I try to print an information in the rule using "print <a string>" phrase in the action part. it's not printing or logging any information in the Systemout.log or standard output console. 

    I was expecting that will print by default in the output console. or Should we configure anything specifically ? 

    we are not using any logging framework.


    ------------------------------
    Satish Kumar
    ------------------------------


  • 2.  RE: print statement is not logging in the standard output console

    Posted Wed August 04, 2021 03:34 PM
    The print statements are captured by the execution unit and returned in the response of the execution.
    In the case of HTDS to retrieve this output you need to enable the trace and enable the filter  outputString=true

    https://www.ibm.com/docs/en/odm/8.10?topic=services-htds-decision-trace-filters


    ------------------------------
    Alain Robert
    ------------------------------



  • 3.  RE: print statement is not logging in the standard output console

    Posted Fri August 06, 2021 12:28 AM
    I have downloaded the HTDS description file with REST --> WADL and the below check list. Generated the java classes from downloaded XSD with JAXB. 

    • Latest ruleset version
    • Latest RuleApp version
    • Decision trace information
    • Inline types in separate XSD files
    In the RES I have added below two properties with true value. 

    • monitoring.filters = true
    • ruleset.trace.enabled = true

    Included TraceFilter with "all=true" and "outputString=true" in the request payload. Below is the screenshot. But getting null value in the response. And nothing prints in the Systemout.log or standard output console.

    Request Payload with TraceFilter value

    Response Result


    With the all=true should we get all the execution results ? What I'm missing here please suggest. 

    Thanks in advance!!




    ------------------------------
    Satish Kumar
    ------------------------------



  • 4.  RE: print statement is not logging in the standard output console

    Posted Fri August 06, 2021 12:51 PM
    This look right, you do not need to enable traces on the ruleset, HTDS will take care of that. 
    Regarding all  I have had mixed success with it, I would not use it and only set the options you need.

    ------------------------------
    Alain Robert
    ------------------------------



  • 5.  RE: print statement is not logging in the standard output console

    Posted Fri August 06, 2021 05:18 PM
    Edited by Satish Kumar Fri August 06, 2021 05:21 PM
    I set the options only what I need as below. And removed traces on the ruleset. But still didn't get Trace details in the response and nothing prints in the Systemout.log or standard output console (I have a print statements in the rule). Not sure what todo next.

    • TotalRulesFired
    • TotalTasksExecuted
    • RulesFired
    • TasksExecuted
    • OutputString


    ------------------------------
    Satish Kumar
    ------------------------------



  • 6.  RE: print statement is not logging in the standard output console

    Posted Tue August 10, 2021 02:07 AM
    Thank you Alain for the information I have used RES Console--> Retrieve HTDS Description File --> REST --> WADL --> Selected --> Latest ruleset version, Latest RuleApp version and Decision trace information --> Test --> Selected Execution Request as JSON (we use JSON request) and cross checked the tracing variables names (It's different from XML request variable) then used the same in my request payload. It worked.  Thank you!! :-)

    ------------------------------
    Satish Kumar
    ------------------------------



  • 7.  RE: print statement is not logging in the standard output console

    Posted Mon August 09, 2021 05:53 AM

    I always thought that in older versions of ODM (or JRules) that the 'print' messages went to the System.out log but they don't any more.

    So what I do now with the 8.10 rule projects is create a virtual helper action verbalised as   "log {0,<message>}"
    with the ARL code as "System.out.println(message);"



    ------------------------------
    Andy Macdonald
    ------------------------------



  • 8.  RE: print statement is not logging in the standard output console

    Posted Tue August 10, 2021 02:18 AM
    I have tried the same thing but in the B2XA System.out.println(message) is not supported got the below errors. And tried with note(message) there is no error but didn't log in Systemout.log or standard output console.

    • [B2X] GBREA0003E: The type 'System' is undefined
    • [B2X] GBREA0031E: Unable to find an attribute named 'System' in type 'com.ibm.rules.engine.ruleflow.runtime.TaskInstance'
    • [B2X] GBREA0072E: Unable to find a variable named 'System'

    Then tried little different called a function from B2XA pck<package>.<function_name>(message).  In the function used System.out.println(message) then the information got logged into Systemout.log or standard output console.

    Thank you!! :-)

    ------------------------------
    Satish Kumar
    ------------------------------



  • 9.  RE: print statement is not logging in the standard output console

    Posted Tue August 10, 2021 04:24 AM
    The old IRL B2X editor was very good at automatically importing any classes that you used in the code (like most Java editors) but in the ARL editor you need to manually import all the classes, even the Systems class.
    So you need to add 'import java.lang.System;' to the imports section of your virtual class as per the image below.


    ------------------------------
    Andy Macdonald
    ------------------------------



  • 10.  RE: print statement is not logging in the standard output console

    Posted Tue August 10, 2021 01:28 PM
    After the "import java.lang.System;" in B2XA System.out.println(message); worked. Thank you Andy!!

    ------------------------------
    Satish Kumar
    ------------------------------