Version: 17.07
Supported Since: 17.01
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.
|
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 |
Log Template * |
Basic |
This parameter which can be a plain text log message or can be any combination of following.
Few example log templates are shown below.
Further following place holders can be used to get the current timestamp.
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.
|
||||
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.
|
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.
Configuration of the Logger processing element is shown below.
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