stewchicken
stewchicken

Reputation: 531

Print out variables in Logger component in MuleSoft Anypoint Studio

If I want to use Logger Component to print variables, it looks like I have to go through below 4 steps

  1. Firstly click “fx” symbol
  2. At Message box write #[vars.employeeId],
  3. Click “fx” symbol again
  4. click save, otherwise I always see error shown on Logger component (marked with yellow color)

Is it work-as-design or it is a bug of anypoint studio IDE, any hints are more than welcome, thank you! enter image description here

Thanks for aled' explaining. i tried the fx button way, it works but IDE gives error hints as below shown. it is very confusing for user . enter image description here

Upvotes: 0

Views: 1304

Answers (1)

aled
aled

Reputation: 25872

You are confusing the usage and syntax. That fx button is optional. It means that the message is a DataWeave expression. In the XML format of the flow it just encloses the entire message into an expression ("#[ ... ]"). If you are doing it the contents must be a valid DataWeave expression, so the string #### employeeId -> must be enclosed in double quotes and must be concatenated to the variable. Using the expression delimiters inside another expression delimiter is not valid. Since it is already an expression you just concatenate the variable: "#### employeeId ->" ++ vars.employeeId.

However if you don't use the fx button you can still use expressions inside the message, then #### employeeId -> #[vars.employeeId] is a valid message for the logger.

Upvotes: 3

Related Questions