Search code examples
mulemule-esb

Mule esb: is "rolling" log files a default behavior?


I have mule 3.8.1. I can see logs for each app I have in %MULE_BASE%/logs/%MULE_APP%.log just like defined in wrapper.conf file. Example log files I have are:

  1. mule-app-APP1.log.2020-04-07
  2. mule-app-APP1.log
  3. mule-app-APP2.log.2020-04-07
  4. mule-app-APP2.log

I understand that by default logs are created in the format %MULE_APP%.log where MULE_APP is mule-app-<app_name>.

My question is about "rolling" files. I mean, creating a new log file each day. There is log4j2.xml in the project but there is only AsyncRoot appender pointing out to Console appender. My question: is the "rolling" log files behavior default in mule ? or there must be a configuration set in the project by someone else, that I'm missing ?


Solution

  • This is not Mule behaviour. This is log4j2 behaviour which is defined in the log4j2.xml file. If you have definition like this

    <RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}myApp.log" 
             filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}myApp-%i.log">
        <PatternLayout pattern="%-5p %d [%t] [event: %X{correlationId}] %c: %m%n" />
        <SizeBasedTriggeringPolicy size="10 MB" />
        <DefaultRolloverStrategy max="10"/>
    </RollingFile>
    

    which is generate automatically when you create myApp mule Application then you will alwyas have only 10 latest rolling logs. If you elimate fileName like this

         <RollingFile name="file"
    filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}myApp-%i.log">
                <PatternLayout pattern="%-5p %d [%t] [event: %X{correlationId}] %c: %m%n" />
                <SizeBasedTriggeringPolicy size="10 MB" />
                <DefaultRolloverStrategy max="10"/>
            </RollingFile>
    

    then you will have behaviour like you described with infinite rolling logs.

    See more about this here https://simpleflatservice.com/mule4/RollingLogFiles.html