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>
Try these expressions:
1) #[message.outboundProperties['originalFileName']]
2) #[header:originalFilename]
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:
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:
Hello World
Try this expression.
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.
I have done almost the same thing a few days ago. Add a
global element
of typeproperty placeholder
, givelocation: mule-deploy.properties
. In logger, use${config.resources}
. It will work if there is only one config file.[name.flow] is not correct one.
you should go with
#[flow.name]
which is the correct form. Don't mislead by your answers.Thanks,