logger

Logger

Version: 17.07

Supported Since: 17.01

What is a Logger?

A Logger is a processing element which can be used to print log lines to the console. Moreover it can be used to log headers, message properties, scope variables, message payload, message id or simply just a plain text message. Logger processing element can be used anywhere in the flow to log above mentioned data and additionally in exceptional paths logger processing element can be used to log the exception message and trace. Logger processing element uses log4j 2.x async logging which is configured using log4j2.xml file.

In order to use this processing element, you must first select the Message Logger dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Message Logger dependency.

Alternatively, you can add the following dependency to the maven pom.xml manually.

<dependency>
    <groupId>org.adroitlogic.x.processors</groupId>
    <artifactId>x-processor-logger</artifactId>
    <version>17.07</version>
</dependency>
logger outports

Out Ports

Next

The message will be sent to this outport if logging is successful

On Exception

The message will be sent to this outport if the processing element failed in logging operation

Parameters

Log Template *

Basic

This parameter which can be a plain text log message or can be any combination of following.

  • @{message.headers.<header_name>} - To log a message header. <header_name> must be replaced with a transport header name. i.e @{message.headers.Content-Type}

  • @{message.headers} - To log all message headers.

  • @{message.properties.<property_name>} - To log a message property. <property_name> must be replaced with a property name.

  • @{message.properties} - To log all message properties.

  • @{message.payload} - To log current payload

  • @{message.id} - To log message id

  • @{mc.properties.<property_name>} - To log a message context property. <property_name> must be replaced with a message context property name.

  • @{mc.properties} - To log all message context properties.

  • @{message.id} - To log message context id

  • @{variable.<variable_name>} - To log a variable. <variable_name> must be replaced with a variable name. i.e @{variable.myvar}

Few example log templates are shown below.

  • Payload: @{message.payload} ContentType: @{message.headers.Content-Type} MessageID: @{message.id} - a log template printing message payload, content-type transport header and message id

  • Successful - simple plain text log message

Further following place holders can be used to get the current timestamp.

  • @{current.timestamp} - this will use the default timestamp pattern yyMMddHHmmssZ

  • @{current.timestamp.<timestamp_pattern>} - this will use the given timestamp pattern. Note that timestamp pattern given here should be a pattern compatible with SimpleDateFormat.

Exception Logging

For exception logging @{last.exception} can be used in log template along with any combination of above expressions. Note that this should be used in an exceptional path in the flow.

Both message property names and variable names are case sensitive like all Java Variables. Therefore exact case of message property name or variable name must be used for the log template in the form @{message.properties.<name>} or @{variable.<name>}.

When @{message.headers.<name>}, @{message.properties.<name>}, @{message.payload} or @{variable.<name>} is used in log template and if the requested values are not found, "null" will be printed for those placeholders.

Log Level *

Basic

Log level for the message. Possible values are as follows. Note that these values have the same meaning as log4j log levels.

  • TRACE

  • DEBUG

  • INFO

  • WARN

  • ERROR

According to the default configuration of log4j2.xml, a log level greater than or equal to INFO will be discarded.

Sample Use Case

In the following use case, logger processing element is used to log message payload, message ID and content-type transport header to the console. Here to demonstrate the logger operation, NIO HTTP Ingress Connector and NIO HTTP Egress Connector is used. Complete flow for the use case is shown below.

logger flow

Configuration of the Logger processing element is shown below.

logger conf

When a message is sent to the endpoint which NIO HTTP Ingress Connector is configured to listen to, following log line will be printed to console.

INFO LoggerProcessingElement Payload: Sample Payload MessageID: d22cfefb-ef01-ff78-0000-000000000004 ContentType: text/xml; charset=UTF-8
In this topic
In this topic
Contact Us