WSO2 Enterprise Integrator 6 min

Separate log files in WSO2 Enterprise Integrator

Wouter van Wijngaarden
Wouter van Wijngaarden
Integration Consultant
log files scaled

WSO2 products use log4j2 for their logging system, so you can always find all the enabled logging aggregated into the wso2carbon.log. Log4j2 is very powerful and worth looking into. In this blog we want to split some of this logging on the API/Proxy level to a separate logfile.

The WSO2 Micro Integrator 4.1.0 (as well as WSO2 EI) supports logging per API or Proxy into their respective files and I’m here to tell you how to do that!

WSO2 products use Apache Log4j2 to enable logging of the components inside the product, this allows for a lot of optional customization by the user. For more info about Apache Log4j2 and the version WSO2 uses you can check out the apache log4j2 documentation.


Inside the Micro Integrator the configuration file for Log4j2 is located in the [MI-HOME]/conf directory with the filename log4j2.properties. This file contains the basic log4j2 configuration used by the product and from here you can modify it as you wish. I am showing this with the Micro Integrator but it also works on the Enterprise Integrator (6.x.0).

Let us create two simple proxies that we can use. Since the Micro Integrator does not have the Echo Service that is by default available on the Enterprise Integrator, I am creating a very simple proxy that responds the message that is send to it with a Log Mediator.

I am using Integration Studio 8.1.0  for this to deploy and also going to use the embedded Micro Integrator that comes with the product.

I am not going to completely show how to install Integration Studio, you can download it from WSO2 and install it on your Windows / Mac or Linux Machine.

Please look at some of our blogs on how to work with Integration Studio or visit one of our trainings.

Integration Project

I am using an Integration project to create the two proxies. The project will be called Log4J2 but you can call it whatever you like.

Nice thing about an integration project is that it creates a config and composite exporter to be able to deploy the proxies you are developing. I am going to keep it simple and take the proposed naming of the modules based on the Project Name.

Separate log files in WSO2

Navigate to project view

Log files - Navigate to project view

I’m creating a new Proxy.

Separate logfiles

I’m calling it EchoProxy and use the Custom Proxy Template.

EchoProxy separate log files

The content is simple

Full log separating files

A full log and a respond will send the message back to the sender.

The code is also simple

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="EchoProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
            <log level="full"/>
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="EchoProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
            <log level="full"/>

The second proxy calls this proxy and is equally simple.

Separate logfiles in WSO EI

This is the code:

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="CallProxy" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
        <endpoint name="Echopoint">
            <address uri="http://localhost:8290/services/EchoProxy">
            <log level="full">
                <property name="Log From " value="CallProxy"/>
separate logfiles WSO Enterprise Integrator

Save both proxies and in the Composite Exporter (the pom file)  Select the two Artifacts. Save this file as well.

LOG4J2 Composite Exporter

Add the server

As there is an embedded MI 4.1.0 it should already be visible. If you do not see the Server tab,  Click on Window / Show View / Other and type in server

Workspace LOG4J2 Composite Exporter
Show view separated logfiles

Click on Open. Right Click the Server and Add and Remove.

separate log files wso2 EI

Click on Finish.

Micro integrator 4.1.0.

Creating a separate log file for designated proxy services

To allow the creation of an extra log file for a specific proxy you just have to add a few lines to the log4j2.properties file. These lines include various parameters which I will explain below. The file can be found at [INT810-HOME]/runtime/microesb/conf

The Appender

Add these lines to the log4j2 properties as the first appender (so before # CARBON_CONSOLE)

appender.ECHO_PROXY_APPENDER.type = RollingFile


appender.ECHO_PROXY_APPENDER.fileName = ${sys:carbon.home}/repository/logs/EchoProxy.log

appender.ECHO_PROXY_APPENDER.filePattern = ${sys:carbon.home}/repository/logs/EchoProxy-%d{MM-dd-yyyy}.log

appender.ECHO_PROXY_APPENDER.layout.type = PatternLayout

appender.ECHO_PROXY_APPENDER.layout.pattern = TID: [%tenantId] [%d] %5p {%c} - %m%ex%n

appender.ECHO_PROXY_APPENDER.policies.type = Policies

appender.ECHO_PROXY_APPENDER.policies.time.type = TimeBasedTriggeringPolicy

appender.ECHO_PROXY_APPENDER.policies.time.interval = 1

appender.ECHO_PROXY_APPENDER.policies.time.modulate = true

appender.ECHO_PROXY_APPENDER.policies.size.type = SizeBasedTriggeringPolicy


appender.ECHO_PROXY_APPENDER.strategy.type = DefaultRolloverStrategy

appender.ECHO_PROXY_APPENDER.strategy.max = 20

appender.ECHO_PROXY_APPENDER.filter.threshold.type = ThresholdFilter

appender.ECHO_PROXY_APPENDER.filter.threshold.level = INFO

appender.CALL_PROXY_APPENDER.type = RollingFile


appender.CALL_PROXY_APPENDER.fileName = ${sys:carbon.home}/repository/logs/CallProxy.log

appender.CALL_PROXY_APPENDER.filePattern = ${sys:carbon.home}/repository/logs/EchoProxy-%d{MM-dd-yyyy}.log

appender.CALL_PROXY_APPENDER.layout.type = PatternLayout

appender.CALL_PROXY_APPENDER.layout.pattern = TID: [%tenantId] [%d] %5p {%c} - %m%ex%n

appender.CALL_PROXY_APPENDER.policies.type = Policies

appender.CALL_PROXY_APPENDER.policies.time.type = TimeBasedTriggeringPolicy

appender.CALL_PROXY_APPENDER.policies.time.interval = 1

appender.CALL_PROXY_APPENDER.policies.time.modulate = true

appender.CALL_PROXY_APPENDER.policies.size.type = SizeBasedTriggeringPolicy


appender.CALL_PROXY_APPENDER.strategy.type = DefaultRolloverStrategy

appender.CALL_PROXY_APPENDER.strategy.max = 20

appender.CALL_PROXY_APPENDER.filter.threshold.type = ThresholdFilter

appender.CALL_PROXY_APPENDER.filter.threshold.level = INFO

And add the Appender to the list

# list of all appenders

#add entry "syslog" to use the syslog appender


#, syslog

This describes the mechanism of the RollingFile appender and the other mechanisms.

It looks like this

Echo Proxy Apprender

The logger

Add to the loggers this line


And this snippet just below that.

logger.SERVICE_LOGGER_EchoProxy.name = SERVICE_LOGGER.EchoProxy

logger.SERVICE_LOGGER_EchoProxy.level = INFO

logger.SERVICE_LOGGER_EchoProxy.additivity = false


It will look like this:


Save the log4j2 file. Start the Server with Right Mouse Click / Start. The changes will be deployed directly.

Save the log4j2 file

Create a new SOAP project in SoapUI based on the http://localhost:8290/services/CallProxy?wsdl

Create a new SOAP project in SoapUI

Open the Service

open service Soap project

And change the message

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">




                  <text>Hello World</text>




Execute. The Response is identical.

Separate log files MI 4.0.1. 3

In SoapUI, invoke the proxy a number of times.

Now go to INT810-HOME]/runtime/microesb/repository/logs and see the new CALLProxy log file

CALLProxy log file

Open the file and see the logs inside.

CALLProxy log file 1

I hope this information helps some people with their projects, if there are any questions don’t hesitate to contact us.

We appreciate it
Care to share

Please select one of the social media platforms below to share this pages content with the world