Change logging in the Mule - mule

I have a Mule project that I want to run from AnypointStudio. It uses the default log4j2.xml, but I want to change that.
According to the documentation (http://www.mulesoft.org/documentation/display/current/Logging+in+Mule), it is posible to put another log4j2.xml file on the classpath, but that does not work.
In the "run configuration" of Anypoint I added a classpath. In that classpath folder I added another log4j2.xml file, but that is ignored by the Mule, although it sees another file in that folder.
How do I add an log4j2.xml file?

Put your log4j2.xml config in src/test/resources, that way it won't be packaged in the app but will be available in Studio, when you launch the app.

Related

One properties configuration file for Multi Apps on Mule ESB runtime

Today I have the same properties configurated on mule-app.properties file for each Apps. Like this:
All Apps (+ that 5) are running on the same Mule ESB runtime (CE).
For example, when It is necessary to change a host or password, I need to change the properties file of the all apps.
I would like to have just one properties file on Mule ESB runtime shared by all apps.
Is there a form to make this?
Thanks!
You can create a new Mule project and call it "shared". Now, in this project, you can create a file src/main/resources/config.properties and there put all the settings you need.
To have these settings in your current project, just add the project "shared" in the "Projects" tab of the "Java Build Path". Then in the main file of your current project, write
< context: property-placeholder location="config.properties" />
Use a Spring Property Placeholder and read a single file from the filesystem:
<context:property-placeholder location="file:/path/to/myConfigFile.properties" />
https://docs.mulesoft.com/mule-user-guide/v/3.6/configuring-properties#properties-files

Accessing mule-app.properties in custom properties file located in src/main/resources on cloudhub

I have a mule application built using mule apikit. The mule-app.properties file contains below property:
orig.db.url=jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;
The custom properties file src/main/resources/dev.properties contains below property:
db.url=${orig.db.url}
And, the mule configuration xml file contains below property-placeholder:
<context:property-placeholder location="dev.properties"/>
Now, when I deploy it locally everything works fine and I am able to run the flow. But, at the same time when I deploy on Cloudhub it gives me below exception:
Invalid bean definition with name 'get:/total_amount:total_amount-db-config' defined in null: Could not resolve placeholder 'orig.db.url' in string value "jdbc:db2://mmrs001.nmd.net:1004/dudu:user=abc43;password=xxxx;"
I am unable to understand what am I missing here?
How did you deploy to CloudHub? If you used the deployment tool from Anypoint Studio you have an option to set properties before deployment.
The mule-app.properties will get added to system properties instead of classpath properties. We can't refer to system properties from property files added to classpath. We need to move these properties to classpath to resolve these in runtime.
One way to override this behaviour by importing mule-app.properties using:
<context:property-placeholder location="mule-app.properties,dev.properties”/>
It tells spring to load properties in respective order. So, first mule-app.properties gets loaded and then dev.properties.
But, its not the best practice to include the mule-app.properties file in the classpath. Best way is to remove the dev properties from mule-app.properties and put it inside dev.properties.
By default when deploying to cloudhub all properties from the mule-app.properties should appear in the properties tab. Did you not see them when you deployed the first time?

How to override mule config file name in Mule Studio?

MuleStudio or its plugin for eclipse uses mule-config.xml file by default. Is there an option to override the file name?
There are two options.
Right click on the Mule Project and go to
Run As --> Run COnfigurations
Then Select Java Application. Then right click and select New
Add your config file name as shown in the picture and run it.
Create a mule-deploy.properties and keep it in the src/main/app folder.
Add the configuration resource entry to it. This will be helpful when you package and deploy mule application onto a mule standalone server.
config.resources=my-mule-config.xml
Refer to the following link for more detials on Mule in Eclipse.
Creating a Mule project in Eclipse
Hope this helps.
you can rename the file by right clicking on it and select refactor or select the file and click F2 to rename it and then run the application as Mule run configurations.

Mule Deployment properties file

I have seen some strange behaviour in Mule Application. I created a sample mule project(created flows) and opened mule-deploy.properties file "config.resources" value is empty.
But the same above mentioned key value is getting updated with "configuration xml file name" when i run my mule project.
Is this the behaviour or any updates need to be done.
Can some clarify?
Regards
Vikram
There are some known issues/features around mule-deploy.properties and Mule Studio.
Currently it is expected that when running your project from Mule Studio that mule-deploy.properties-config.resources is automatically populated with all your configuration files.
There are some open issues on this here: https://www.mulesoft.org/jira/browse/STUDIO-3297 that you can vote on.
Once you run the mule application it will automatically updated with the configuration file by default if you have only one main configuration file.But If you are using more configuration files in your application you should manually add all the filenames to the config.properties key separated by comma before run the application.

Using Netbeans to configure context-root for JBoss

I have a Spring application that is being deployed to JBoss 4.2. I can manually edit the generated WAR file and alter the jboss-web.xml file to set the context-root value and that works perfectly well. I would like to be able to do the samething via netbeans (6.9.1), but I have been unable to locate where to make the adjustment. I've tried tweaking the project's properties and setting the Context Path value. When I Run the application that value is reset to the Project's name. I've located the jboss-web.xml file in the project and changed it there, also reset upon run. So it appears that Netbeans is deciding that the value need to be set but I can't locate where. If it's of any use, the project also uses Maven2, but all the controls I can find for impacting context-root are geared towards EAR files instead of WAR.
Has anyone been able to do this or am I just in a world of making the change post build?
I had a similar problem once where netbeans was sometimes removing the context-root element from the glassfish-web.xml configuration. I have not been able to track it down exactly but you could try to remove the file nb-configuration.xml in the project root folder and see if that helps.