# An example of running a Microservice Route using external Log4j configuration

Availability-note[Deprecated](https://help.talend.com/r/en-US/Cloud/labels-on-talend-help-center/availability-deprecated)

This content is deprecated.

Available in...

* Cloud API Services Platform
* Cloud Data Fabric
* Data Fabric
* Data Services Platform
* ESB
* MDM Platform
* Qlik Cloud Enterprise Edition
* Qlik Talend Cloud Enterprise Edition
* Qlik Talend Cloud Premium Edition
* Real-Time Big Data Platform

This section will show you an example of how to run a Microservice Route using external Log4j configuration.

The Microservice is built from a simple Route containing a cTimer and cLog component.

![Route example.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example1.png)

The cTimer component will trigger the message exchange five times.

![Basic settings view of the cTimer component.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example2.png)

The cLog component will log the message exchanges. The logging level is set to WARN, which is the default configuration of Talend Studio.

![Basic settings view of the cLog component.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example3.png)

When running the Route in Talend Studio, the following result is shown in the execution console.

![Basic run view.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example4.png)

After building the Route to the Microservice .jar file, you can run it in a console window:

* To run the Microservice with the default configuration, use the following command:

  ```
  java -jar demo_0.1.jar
  ```

  The following log messages are shown, which is the same as the execution result in Talend Studio.

  ![Log messages in the command line.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example5.png)

* To run the Microservice with a custom Log4j configuration, you can use the spring.config.additional-location property to call the customized log4j.xml file in an external configuration folder. A sample Log4j configuration which is located in the config folder in the directory of the Microservice jar is shown below to provide a tesb.log file when the Microservice is started.

  ```
  <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
      <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
          <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%d | %-5.5p | %-16.16t | %-32.32C %4L | %m%n"/>
          </layout>
      </appender>
      <appender name="rollingFile" class="org.apache.log4j.RollingFileAppender">
          <param name="file" value="tesb.log"/>
          <param name="MaxFileSize" value="1024KB"/>
          <param name="MaxBackupIndex" value="10"/>
          <layout class="org.apache.log4j.PatternLayout">
              <param name="ConversionPattern" value="%d | %-5.5p | %-16.16t | %-32.32C %4L | %m%n"/>
          </layout>
      </appender>
      <root>
          <priority value="info"/>
          <appender-ref ref="stdout"/>
          <appender-ref ref="rollingFile"/>
      </root>
  </log4j:configuration>
  ```

  To use this configuration, run the following command:

  ```
  java -jar demo_0.1.jar --spring.config.additional-location=./config
  ```

  Alternatively, you can use the logging.config property to call the Log4j configuration file:

  ```
  java -jar demo_0.1.jar --logging.config=./config/log4j.xml
  ```

  The following log messages are shown, and written to the tesb.log file in the directory where the Microservice jar file is located.

  ![Log messages in the command line.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example6.png)

  The tesb.log file is created:

  ![The tesb.log file is located in Computer > New Volume (F:) .](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example7.png)

  The log messages are written to the tesb.log file:

  ![Content of the tesb.log file.](https://help.qlik.com/talend/en-US/studio-user-guide/Resources/images/studio_di_esb-microservice-example8.png)