Loading

How to configure log4j for Mule Applications and service to send logs to Fluentd infrastructure

Publiseringsdato: Aug 5, 2025
Trinn

CONTENT

Fluentd is an open-source data collector software that can be used to route and process application logs. The mule services and applications running on them can also be configured to forward logs to Fluentd service for further process


STEPS TO FOLLOW

Step 1: Make changes to the log4j.xml to include the classes that are required for the service to push forward the logs. (The below sample uses packages wycore_log4j-plugin-fluency and komamitsu_fluency to demonstrate the functionality.  Check the links for the latest information and further configurations)

<?xml version="1.0" encoding="utf-8"?>
    <Configuration packages="com.wywy.log4j.appender,org.komamitsu.fluency.Fluency">
Step 2: Include the changes in the log4j.xml for Fluentd related configurations. Also, configure the AsyncRoot for the new fluentd appender.
.....
.....
.....
<Appenders>
        <Fluency name="fluency" tag="yourTag">
            <!-- all settings are optional, see defaultFluency() for default values -->
            <!-- you can add as may fields as you like (or none at all) -->
            <StaticField name="application">yourApplication</StaticField>
            <StaticField name="someOtherField">some value</StaticField>
            <Server host="primary-node" port="24224"/>
            <Server host="secondary-node" port="24224"/>
            <FluencyConfig
              ackResponseMode="true"
              fileBackupDir="/tmp/fluency"
              bufferChunkInitialSize="4194304"
              bufferChunkRetentionSize="16777216"
              maxBufferSize="268435456"
              waitUntilBufferFlushed="30"
              waitUntilFlusherTerminated="40"
              flushIntervalMillis="200"
              senderMaxRetryCount="12" />
        </Fluency>
</Appenders>
.....
.....
        <AsyncRoot level="INFO">
            ......
            ......
            <AppenderRef ref="fluency"/>
            ......
            ......
        </AsyncRoot>
For Mulesoft Application logs, the "log4j.xml" wrapped in the application must be updated.
For Mulesoft Service[mule_ee* ] logs, the "log4j.xml" in the "{MULE_HOME}/conf" must be updated 

Step 3: Package the required libraries to the application or service for which fluentd is being implemented.
For Mulesoft Application logs, the dependent libraries can be added to the POM.xml so that the deployable package contains the required libraries wrapped. The example shown below,
<dependency>
  <groupId>com.wywy</groupId>
  <artifactId>log4j-plugin-fluency</artifactId>
  <version>1.3.2</version>
</dependency>
For Mulesoft Service[mule_ee* logs], Identify and collect all the dependent jars and place them in the file system[For example, {MULE_HOME}/lib/user/] where mule is installed. Then edit the "wrapper.conf" file to include that path to load the fluentd service-related jar files.
wrapper.java.classpath.<n>=<PATH TO THE FOLDER CONTAING JAR FILES>/*.jar

Step 4: Restart the mule application/service to make sure the changes are effective, no errors are reported. 
 

Common ErrorsCauseSolution
WebSocketInboundExecutor ERROR Appenders contains an invalid element or attribute "Fluency"
WebSocketInboundExecutor ERROR Unable to locate appender "fluency" for logger config "root"
This error occurs when the libraries are not identified by the running service or application.Check of the required libraries are packaged/placed manually in the mentioned Step 3

 

Disclaimer: This example is provided as a reference for your own usage and is not to be considered a MuleSoft product. This example should be considered as a custom solution. The custom solution is not a Supported MuleSoft product.
 
Knowledge-artikkelnummer

001116589

 
Laster
Salesforce Help | Article