Author: Mohammad Mazhar Ansari

CloudHub stores up to 100 MB of log data per application per worker, or up to 30 days, whichever limit is reached first. This is not applicable for clients who have Titanium subscription. For Titanium Subscription, you will get 200 GB per production core.

The objective of this blog is to discuss a generic approach which can help clients to download application log files if they are not using any centralized logging server with MuleSoft.

MuleSoft Options to Overcome such issue:

  • Manually download log files
  • Anypoint CLI
  • Anypoint CloudHub Public API

In this blog, we will discuss option #2 and try to create scripted solutions for the same.

Anypoint CLI:

  • Anypoint Platform provides a scripting and command-line tool for both Anypoint Platform and Anypoint Platform Private Cloud Edition (Anypoint Platform PCE).
  • The command-line interface (CLI) supports both the interactive shell and standard CLI modes.
  • Anypoint CLI is a NodeJS based application which works on all kinds of operating systems.

Anypoint CLI Installation:

Shell Script Overview: 

Below Algorithm is used.

  • Find all deployed and running application in a particular environment
  • Download Log Files one by one
  • Line #1 defines which shell to use for execution
  • Line #3 – 8 check if correct parameters are passed of not
  • Line #11 – 13 set Anypoint related variables
  • Line #16 set Anypoint CloudHub Environment Name
  • Line #17 set the file directory
  • Line #19 get all deployed and running applications in a particular environment
  • Line #21 – 24 download the log files one by one

Execution:

  • Create a file named downloadLogFiles.sh and save it on Unix system
  • Change permissions of file to execute it
  • Run the command
  • It will download all files in given directory

Note: This script can be modified and used in Windows System as well.

Leave a Comment