Sending Logs of On-Premise Application to Splunk

Author: Kishori Patil

Splunk can read different types of data. After reading the data, it allows search, tag, create reports and dashboards on these data.Mule applications can be configured to send logs to splunk.


There are 2 ways to send logs to Splunk :

1. HTTP Appender   2. Splunk HTTP Appender .

This blog contains steps to send logs from on-premise applications to Splunk using Splunk Http appender.

1.Create a token in Splunk

2.Configure log4j2.xml file

3.Add dependencies in pom.xml

Create a token in Splunk:

HTTP Event Collector allows you to send data and application events to a Splunk deployment over the HTTP and HTTPS protocols. Using token you can send data  to splunk.You do not need to include Splunk credentials in your application.

  1. Goto splunk UI and select setting >Data inputs.create a new HTTP Event Collector using add new.
  1. Provide any name to your token and press next.
  1. Then select a Source type that is log4j as we are sending logs to splunk using log4j.
  1. Then select all indexes and make Main as Default index.
  1. Summary of your token looks something like this :
  1. New token is created, which we will use as authorization for splunk. 
  1. Now go to settings>Data inputs>HTTP Event Collector. You can see the new token created.
  1. Go to Global Settings and Enable all Tokens by clicking on Enabled. also add HTTP port as 8088, now your HTTP Event collector will listen on this port.To make HTTP Event collector to  listen and communicate over HTTPS rather than HTTP, click the Enable SSL checkbox.
  1. If you click on edit you can change any configuration of that token. You can also add a description of that token ,name for source .
Configure log4j2.xml file:
  1. Open src/main/resources/log4j2.xml add the following Splunk HTTP appender to appenders .For sending logs to Splunk from the MuleSoft application, you need to provide an url of splunk for us its “https://localhost:8088” and for Authorization add Token which we have created in splunk.

<SplunkHttp name=”splunk” url=”https://localhost:8088/”

token=”7acf9ccb-02a1-482e-a895-ba4ce3934eae” index=”main”



pattern=”%-5p %d [%t] [event: %X{correlationId}] %c: %m%n” />


  1. Then add AppenderRef which is nothing but your SplunkHttp name .<AsyncRoot> in the following image Sends the INFO level logs to splunk and Console.depending on your requirement you can decide which level logs you want to send to splunk.
Add dependencies in pom.xml:
  1. Add the following dependencies in your pom.xml dependencies section for Splunk.
















  1. Add following repository in the repositories tag of pom.xml



<name>Splunk Releases</name>



  1. Once all the above configurations are done your application is ready to send logs to splunk.Deploy your application and make a call to it .whatever logs you can see in console are also send to splunk(logs are send depending upon your config in log4j).you can decide based on your requirement which logs you want to print in console and which you want to send to splunk.
Searching logs in Splunk:

To see logs go to Splunk>Apps>Search & Reporting :

As you can see in the above image you can either type string to search in the search box or click on data summary.

In the Data Summary there are 3 options available : hosts,Sources,SourceType.Depending upon your choice you can select one . Suppose if we are selecting Sources then you can see it’s the same name which we have added to the source of the token we created. Clicking on this will show logs for this source.

You can create separate tokens for different applications so that you can monitor logs separately. 

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.