<!doctype html> <html> <head> <title>Log Object</title> <link rel="stylesheet" href="styles/site.css" type="text/css"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="styles/icons.css" type="text/css"> <script src="js/jquery.min.js"></script> <script src="tree/collapsibleTreeMenu.js"></script> <link href="tree/collapsibleTreeMenu.css" rel="stylesheet" type="text/css"> </head> <body class="theme-default aui-theme-default"> <div id="page"> <div id="main" class="aui-page-panel"> <div id="main-header"> <div id="breadcrumb-section"> <ol id="breadcrumbs"> <li> <span><a href="Rhapsody-Integration-Engine-6.5_133160975.html">Rhapsody Integration Engine 6.5</a></span> </li> <li> <span><a href="Developing-Rhapsody_133161055.html">Developing Rhapsody</a></span> </li> <li> <span><a href="JavaScript-Object-Reference_133161390.html">JavaScript Object Reference</a></span> </li> <li> <span><a href="Global-Objects_133161405.html">Global Objects</a></span> </li> </ol> </div> <h1 id="title-heading" class="pagetitle"> <span id="title-text">Log Object</span> </h1> </div> <div id="content" class="view"> <div id="main-content" class="wiki-content group"> <p>The Log object allows JavaScript functions to log messages to the Rhapsody log files.</p> <div class="confluence-information-macro confluence-information-macro-note"> <span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span> <div class="confluence-information-macro-body"> <p>The use of loggers in production scenarios with high traffic volumes can result in Rhapsody running out of disk space.</p> </div> </div> <h2 id="LogObject-Methods">Methods</h2> <div class="table-wrap"> <table class="confluenceTable"> <tbody> <tr> <th class="confluenceTh"><p>Method</p></th> <th class="confluenceTh"><p>Description</p></th> </tr> <tr> <td class="confluenceTd"><p><code>debug(Object)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The object's <code>toString</code> method is called to generate the string to be logged.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>debug(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwable printStackTrace method.</p><p>This information is only added to the log if the Rhapsody log-level is set to DEBUG or higher.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>info(Object)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>info(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwables <code>printStackTrace</code> method.</p><p>This information is only added to the log if the Rhapsody log-level is set to INFO or higher.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>warn(Object)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>warn(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwables <code>printStackTrace</code> method.</p><p>This information is only added to the log if the Rhapsody log-level is set to WARN or higher.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>error(Object)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>error(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwables <code>printStackTrace</code> method.</p><p>This information is only added to the log if the Rhapsody log-level is set to ERROR or higher.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>fatal(Object)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>fatal(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwables printStackTrace method.</p><p>This information is only added to the log if the Rhapsody log-level is set to FATAL.</p></td> </tr> <tr> <td class="confluenceTd"><p><code>trace(Object, Throwable)</code></p></td> <td class="confluenceTd"><p>Logs the object's string representation to the Rhapsody log file. The <span>object's</span> <code>toString</code> method is called to generate the string to be logged along with the stacktrace generated by calling the throwables <code>printStackTrace</code> method.</p><p>This information is only added to the log if the Rhapsody log-level is set to TRACE or higher.</p></td> </tr> </tbody> </table> </div> <h2 id="LogObject-Example">Example</h2> <p>The following example displays how the Log object can be used in a JavaScript filter. This code processes a message normally, but logs the value of a field <code>AcknowledgementCode</code> in the <code>MSA</code> segment, at the WARN log level. An appropriate message definition is required to be associated with the route.</p> <div class="code panel pdl" style="border-width: 1px;"> <div class="codeContent panelContent pdl"> <pre class="syntaxhighlighter-pre" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence">for (var i = 0; i < input.length; i++) { var next = output.append(input[i]); log.warn("Value of MSA.AcknowledgementCode is " + next.getField("MSA.AcknowledgementCode")); } </pre> </div> </div> <h2 id="LogObject-FilterExceptionsandErrors">Filter Exceptions and Errors</h2> <p>A filter that indicates errors by calling <code>Message.addError()</code>, or by throwing an exception out of the filter, has its errors available through the <code>getErrors()</code> method available in JavaScript.</p> <ul> <li>If any exception is thrown out of a filter while processing a message, the exception message and the name of the filter are added as an error to the message, allowing subsequent retrieval using the <code>getErrors()</code> method.</li> <li>If the exception has a nested cause (for example, a nested exception), all the messages from the nested exceptions are also added as errors to the message (identified as nested exceptions).</li> <li>If an exception is thrown out of a filter, any other changes made to the message by the filter are discarded.</li> <li>If the thrown exception is a <code>FilterProcessingException</code> (or a derived class), this indicates an error with the message, so the message is sent to the error connector of the filter.</li> <li>If the thrown exception is any other type, the message is sent directly to the error queue (as it generally indicates an issue with the filter rather than the message).</li> <li>If the message is sent to the error connector, but there is nothing connected to the error connector for this filter, the message is sent to the error queue.</li> <li>If an exception is thrown when there were multiple input messages (for example, a collector), the exception error messages are added to all the input messages and all messages are sent to the error connector or error queue.</li> <li>If a filter explicitly adds errors to the message using the <code>addError()</code> method, the message is sent to the error connector once it leaves the filter. Unlike when an exception is thrown, any changes made to the message in this case are saved (as the filter did complete execution).</li> </ul> <p> </p> </div> </div> </div> </div> </body> </html>