Sending Mulesoft Application Logs to AWS CloudWatch

4/14/2025

What is AWS Cloudwatch?

AWS CloudWatch serves as a comprehensive solution for storing, accessing, and deriving valuable insights from log files. This powerful service facilitates the consolidation of logs from various sources including systems, applications, and AWS services into a single, scalable platform. Users can conveniently view, search for specific error codes or patterns, filter logs based on specific criteria, and securely archive them for future analysis.

1. Create an AWS Account.

2. Login to AWS Account.

Section 1: AWS Cloudwatch Stream Creation 

STEP-1  CloudWatch Configuration 

 1. Navigate to Console and Search for Cloudwatch.
 


2. Select Log Group and  Click on Create Log Group.

3. Give the name and click on create.


4. Click on Anypintlogs Name and then click on create log stream.


 

STEP-2 IAM Configuration

We would need the Access Key and Secret Key and region where log steam is created to access the stream from Anypoint. You can get it on IAM following below steps: 

 1. Search for IAM from the console. 

2. Select Manage Access Key.

3. Create New Access Key and note down the Secret Key (i.e. generated once while the create of Access Key)

Section 2: Anypoint Studio.

Step-1 Create a Sample Project

1. Click on File → New → Mule Project.

2. Enter the project name and click on finish.

3. Create a Sample Flow.

STEP-2 Application Configuration

POM.XML

1. We need to add the below 2 dependencies in the POM file of the Project.

 2. We need to update the Log4j2.xml file of the Project.

a) Add kdgregory configuration package

 

 

 

 

Section 3: Deployment 

1) Deployment on Anypoint Studio (Local) 

Post Configuration of the all the steps, We have to pass the access key, Secret Access Key, Region, Log Group Name and Log Stream Name as Runtime Argument on Anypoint Studio 

Arguments 

    1 -Daws.accessKeyId= ********* 

    2 -Daws.secretKey=******** 

    3 -Daws.region=******** [example: “us-east-1” ] 

    4 -Dlog.group.name=your-Log-Group-Name [example: “Anypointlogs”] 

   5 -Dlog.stream.name=your-Log-Steam-Name [example: “Stream”]

2) Deploy in the studio

3) Hit the url in the postman.

4) Go into the cloudwatch to check the logs

 

Conclusion:

By following the above steps, you can successfully stream MuleSoft application logs to AWS CloudWatch, enabling centralized log management and better observability of your APIs and integrations. This not only enhances visibility but also simplifies troubleshooting and performance tracking.
With proper access control and a scalable logging solution in place, your application monitoring becomes more powerful and efficient—giving you the insights you need, when you need them.