logger

Logger

Version: 17.01

Supported Since: 17.01

What is a Logger?

A Logger is a processing element which can be used print to 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. Logger processing element uses log4j 2.x async logging which is configured using log4j2.xml file.

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

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

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

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

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.

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.

In this topic
In this topic
Contact Us