This is one I’ve seen recently in some un edited log4j2.xml files:

<RollingFile name="RollingFile"

What’s wrong with this?  So many things…

What happens if I move this server?  What happens if I move the app?  Especially if I have two servers on the same machine.

Use instead:

   <Property name="logDir">${sys:mule.home}/logs</Property>
   <Property name="appName">myapp/Property>
    <RollingFile name="diagnostic" fileName="${logDir}/mule-app-${appName}.log"
    <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n" />
    <TimeBasedTriggeringPolicy />

Now you a variable that you edit at the top of every log4j2.xml file that will say the app name.  You can then use a basically universal config file for all your apps

To make your logger setup complete, you also need to add the category field to every logger, the naming convention I use is:


  1. This gives you the ability to set the level of logging specific to your loggers in an app different from any built in Mule loggers
  2. This will log the flow name in the log file that produced a particular log line.  In the above logging config the

    enables this.

  3.  <Logger name=”com.mycompany” level=”INFO”/> is now customizable in the log4j2.xml

One final note about this.  The


as a variable requires that mule home is set effectively on your server. Sometimes this is inconsistent on mule servers started in an inconsistent way. Use the Mule as a Service to make this enterprise-grade.

Full Example log file