pp108 : Logger

Logger


To use Composite Application Logging, a Web application must have the infrastructure to log messages. To achieve Web logging capabilities, the logging framework in the Java layer has been extended by a generic logging service. The generic logging service is provided by the logger library.

The request sent by the logger library is as follows:

<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Body>
        <LogMessage xmlns="http://schemas.cordys.com/log/1.0/">
            <DC name="user">The user DN</DC>
            <DC name="url">The URL of the application</DC>
            <DC name="applicationID">The application ID used by BDI</DC>
            <DC name="fileName">The htm or js file name where the log message is originating</DC>
            <DC name="BPM Name">MyProcess</DC>
            <Level>INFO</Level>
            <Message>Custom messsage</Message>
        </LogMessage>
    </SOAP:Body>
</SOAP:Envelope>


The various methods defined for this component are as follows:

Table 1. List of Methods

Method

Description

getLoggerContext()

Retrieves the logger context set for the Web application

log(sLogLevel, sLogMessage)

Sends the log request to the back end

The possible values are:

  • sLogLevel: String that denotes the log severity of the message. It accepts values such as DEBUG, INFO, WARN, ERROR, and FATAL
  • sLogMessage: String that holds the message to be logged

setDiagnosticContext(sContextName, sContextValue)

Sets the diagnostic context for a Web application

The possible values are:

  • sContextName: String that denotes the diagnostic context name
  • sContextValue: String that denotes the corresponding diagnostic context value

setLoggerContext(ologgerContextXML)

Sets the logger context for a Web application. This method overwrites the system generated logger context of the application. The logger context can be set using the following format:

<Logger>
    <DC name="ApplicationName">My Composite Application</DC>
    <DC name="correlationID">8d3a0e69-0ac0-4541-015b-0afddd34f6f7</DC>
    <DC name="hopCount">0</DC>
</Logger>

getEncodedLoggerContext(oInputXMLNode)

Sends a request to the CompressAndEncode Web service to compress and encode an XML node. Returns a JavaScript object that holds the encodedXMLString and actualLength corresponding to the response from the Web service.The oInputXMLNode attribute is optional. It denotes the XML node to be compressed and encoded. If not defined, the node is taken from the cache.

<Logger>
    <DC name="ApplicationName">My Composite Application</DC>
    <DC name="correlationID">8d3a0e69-0ac0-4541-015b-0afddd34f6f7</DC>
    <DC name="hopCount">0</DC>
    <Level>ERROR</Level>
</Logger>
enrichRequestWithLoggerContext(request) Appends the logger related details to the request. This must be done before sending the request.
isDebugEnabled Returns true if the Logger is enabled for debugging (DEBUG)
isInfoEnabled Returns true if the Logger is enable for information (INFO)
isWarningEnabled Returns true if the Logger is enable for a warning (WARN)
isErrorEnabled Returns true if the Logger is enable for an error (ERROR)
isFatalEnabled Returns true if the Logger is enable for a fatal error (FATAL)

Example

The following sample code demonstrates the use of methods to set a custom diagnostic context for a Web application.

var loggerObject = application.getLogger();
loggerObject.setDiagnosticContext("myContext", "myBusinessProcess");