0

I want to print the mule configuration file name, in the logger in the flow, how can I get it?

Suppose the configuration file name in test.xml, inside that a flow is having logger, which prints test.xml, how can I get this?

<flow name="filenameFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/Hello" doc:name="HTTP"/>
    <logger message="#[app.name.toString()]" level="INFO" doc:name="Logger"/>
</flow>
sulthony h
  • 1,279
  • 1
  • 8
  • 9
Prasad
  • 33
  • 3
  • 11

6 Answers6

0

Should print out the name of your application, in you case "test". This is not however the name of the xml file. #[flow.name] will give you the name of the flow currently executing.

dlb
  • 357
  • 3
  • 13
  • i want the name of the xml file – Prasad Aug 30 '16 at 05:41
  • I want the xml name in which flow name is there, not the flow name, is there any way? – Prasad Aug 30 '16 at 11:21
  • Not to my knowledge, but there may be other less documented features like flow.name that would do it. I doubt it however as, at least in my view, the name of the .xml file containing the code is not a meaningful object. The xml files are simply convenient containers for organizing your application and have no actual functional properties to the application, while the flow name and application name do. With them, good naming patterns would help find the xml file easily, and worst case a simple text search for the flow name would find it and correlate to the real object, the flow. – dlb Aug 30 '16 at 15:23
0

[name.flow] is not correct one.

you should go with #[flow.name] which is the correct form. Don't mislead by your answers.

Thanks,

Community
  • 1
  • 1
vijay dhanakodi
  • 175
  • 1
  • 14
0

Try these expressions:

1) #[message.outboundProperties['originalFileName']]

2) #[header:originalFilename]

nemo
  • 11
  • 2
0

I have done almost the same thing a few days ago. Add a global element of type property placeholder, give location: mule-deploy.properties. In logger, use ${config.resources}. It will work if there is only one config file.

Abhay
  • 314
  • 1
  • 2
  • 11
0

Just as @dlb explained, I am also wondering you may have better solution for your requirement, basically I am asuming that you want to make log more transparent, and easier to locate which flow caused any event/error.

As such, it makes more sense to log flow name rather than the config file name, which may contain multiple flows.You can utilize the catagory in log component for this purpose:

<logger level="INFO" category="${application-prefix}.myMainFlow" doc:name="Logger" message="#['payload is ---\n' + payload]"/>

In each and every log component (logs should be used in important places kind of milestones), input ${application-prefix}.flowName in catagory (property is used for reusing application's name in all logs, and flowName should be hardcoded), then you will find logs like below in runtime:

INFO  2016-09-07 17:00:27,566 [[test].HTTP_Listener_Configuration.worker.01] com.myOrg.myApp.myMainFlow: payload is ---

Hello World

Robert
  • 17
  • 3
  • 8
0
#[message.outboundproperties[originalFilename]]

Try this expression.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253