This documentation is for WSO2 API Manager 2.6.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Content Zone
locationtop

Step 1 - Configure observability

  1. Add the Log4J configurations so that a log file is created for the purpose of observability when API Manager server is started.
    Add the following code to the <API-M_HOME>/repository/conf/log4j.properties file. 

    Code Block
    # correlation logs
    log4j.logger.correlation=INFO, CORRELATION
    log4j.logger.MessageTracker=INFO, CORRELATION
    log4j.additivity.correlation=false
    # Appender config for correlation logs
    log4j.appender.CORRELATION=org.apache.log4j.RollingFileAppender
    log4j.appender.CORRELATION.File=${carbon.home}/repository/logs/${instance.log}/correlation.log
    log4j.appender.CORRELATION.MaxFileSize=10MB
    log4j.appender.CORRELATION.layout=org.apache.log4j.PatternLayout
    log4j.appender.CORRELATION.Threshold=INFO
    log4j.appender.CORRELATION.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}|%X{Correlation-ID}|%t|%m%n

    Note that the maximum file size of the correlation log is set to 10MB by default in the above configuration, which means that when the size of the file exceeds 10MB, a new log file is created. If required, you can change this file size.

  2. Add the valve configurations for the purpose of deriving the correlation ID.
    Add the following configurations under the <Host> tag in the <API-M_HOME>/repository/conf/tomcat/catalina-server.xml file.

    Code Block
    <Valve className="org.wso2.carbon.tomcat.ext.valves.RequestCorrelationIdValve" headerToCorrelationIdMapping="{'activityid':'Correlation-ID'}" queryToCorrelationIdMapping="{'RelayState':'Correlation-ID'}"/>
  3. Add the Synapse Handler configurations to facilitate external call logging.
    Add the following configurations as a handler after the <handler> tag in the <API-M_HOME>/repository/conf/synapse-handlers.xml file.

    Code Block
    <handler name="externalCallLogger" class="org.wso2.carbon.apimgt.gateway.handlers.LogsHandler"/>

Step 2 - Enable observability


Note

Skip this step if you want to pass the system property to enable observability at the time of starting the WSO2 API-M server.

You can choose either one option below.

Lightweight observability

Note
  • Enable either lightweight observability or full observability at a time while debugging issues.
  • Lightweight observability does not log logs related to method calls and database calls.
  • You need to get the latest product updates for your product to use this lightweight observability feature in the current version of WSO2 API-M. This feature is available as a product update in WSO2 API-M 2.6.0 from June 10, 2021 onwards.

    Warning

    Note that you can deploy updates in a production environment only if you have a valid subscription with WSO2. Read more about WSO2 Updates.

Since enabling full observability impacts WSO2 API Manager's performance, a lightweight observability option is introduced only to log info related to API calls for message tracking purposes. If you want these message tracking logs to be enabled every time the server starts, add the following system property to the product startup script (stored in the <API-M_HOME>/bin/ directory) and set it to true.

Localtab Group
Localtab
activetrue
titleLinux/Mac OS

Add the following configuration as a system property to the <API-M_HOME>/bin/wso2server.sh file. By default, this is set to false.

Code Block
-DenableMessageTrackingLogs=true \
Tip

Make sure to add it before the org.wso2.carbon.bootstrap.Bootstrap $* line.

Localtab
titleWindows

In a Windows environment, append the following system property to CMD_LINE_ARGS in the <API-M_HOME>\bin\wso2server.bat file as follows:

Code Block
-DenableMessageTrackingLogs=true


Full observability

If you want correlation logs to be enabled every time the server starts, add the following system property to the product startup script (stored in the <API-M_HOME>/bin/ directory) and set it to true.


Localtab Group
Localtab
activetrue
idlinuxMacOS1
titleLinux/Mac OS

Add the following configuration as a system property to the <API-M_HOME>/bin/wso2server.sh file. By default, this is set to false.

Code Block
-DenableCorrelationLogs=true \
Tip

Make sure to add it before the org.wso2.carbon.bootstrap.Bootstrap $* line.

Localtab
idwindows1
titleWindows

In a Windows environment, append the following system property to CMD_LINE_ARGS in the <API-M_HOME>\bin\wso2server.bat file as follows:

Code Block
-DenableCorrelationLogs=true


Step 3 - Start the WSO2 API-M server

Start the WSO2 API-M server.

Localtab Group
Localtab
activetrue
idLinuxMacOS
titleLinux/Mac OS
  • If you have enabled observability before, navigate to the <API-M_HOME>/bin directory and run the following command.

    Code Block
    sh wso2server.sh
  • If you have not enabled observability before, navigate to the <API-M_HOME>/bin directory and enable observability at the time of starting the WSO2 API-M server as follows:

    • for lightweight observability

      Code Block
      sh wso2server.sh -DenableMessageTrackingLogs=true start
    • for full observability

      Code Block
      sh wso2server.sh -DenableCorrelationLogs=true start
Localtab
idWindows
titleWindows
  • If you have enabled observability before, navigate to the <API-M_HOME>\bin directory and run the following command.

    Code Block
    wso2server.bat --run
  • If you have not enabled observability before, navigate to the <API-M_HOME>\bin directory and enable observability at the time of starting the WSO2 API-M server as follows:

    • for lightweight observability

      Code Block
      wso2server.bat --run -DenableMessageTrackingLogs=true
    • for full observability

      Code Block
      wso2server.bat --run -DenableCorrelationLogs=true start
Note

When observability is enabled in WSO2 API Manager, a separate log file named correlation.log is created in the <API-M_HOME>/repository/logs directory.

...