Blacklisting the threadsCertain threads continuously print unnecessary logs. Blacklisting prevents the unwanted threads from printing logs thereby improving the readability of the logs. Follow the steps below to configure thread blacklistingdenylisting. - Open either of the following files in the
<IS_HOME>/bin directory on a command prompt.- For Mac/Linux:
wso2server.sh file - For Windows:
wso2server.bat file
Add the following configuration as a system property. Code Block |
---|
-Dorg.wso2.CorrelationLogInterceptor.BlacklistedThreads=threadName1,threadName2 \ |
Tip |
---|
Make sure to add it before the org.wso2.carbon.bootstrap.Bootstrap $* line. |
Note |
---|
This configuration is not required by default, as all unnecessary threads are already blacklisted denylisted by the MessageDeliveryTaskThreadPool thread. If the above configuration is added, the default value will be overridden. |
Restart the WSO2 IS server. Code Block |
---|
sh wso2server.sh -DenableCorrelationLogs=true stop
sh wso2server.sh -DenableCorrelationLogs=true start |
By default, RequestCorrelationIdValve in the catalina-server.xml file in the <IS_HOME>/repository/conf/tomcat directory is configured to map to the value sent by the activityid header as the Correlation ID . You can change this by editing the RequestCorrelationIdValve by replacing the activityid with any other headerName that you will be sending. Let's consider an authentication request that is sent with a new header configuration. Change the RequestCorrelationIdValve in the cataline-server.xml file to the value given below. Code Block |
---|
<Valve className="org.wso2.carbon.tomcat.ext.valves.RequestCorrelationIdValve"
headerToCorrelationIdMapping="{'customHeader':'Correlation-ID'}" queryToCorrelationIdMapping="{'RelayState':'Correlation-ID'}"/> |
Restart the WSO2 IS Server. Code Block |
---|
sh wso2server.sh -DenableCorrelationLogs=true stop
sh wso2server.sh -DenableCorrelationLogs=true start |
To send the authentication request, execute the following cURL command. Code Block |
---|
curl -v -k -X POST --basic -u <CLIENT_KEY>:<CLIENT_SECRET> -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -H "customHeader:correlationvalue" -d "grant_type=client_credentials" https://localhost:9443/oauth2/token |
Tip |
---|
Use the client key and client secret of the service provider you created after enabling product observability |
Open the correlation.log on a command prompt and notice the related logs. Code Block |
---|
tail -f ../repository/logs/correlation.log |
Even though the default configuration maps a single header to a single Correlation ID, it is possible to add multiple headers and map them to multiple Correlation IDs. Let's consider an authentication request that is sent with multiple headers. Change the RequestCorrelationIdValve in the cataline-server.xml file to the value given below. Code Block |
---|
| <Valve className="org.wso2.carbon.tomcat.ext.valves.RequestCorrelationIdValve"
headerToCorrelationIdMapping="{'customHeader1':'Correlation-ID', 'customHeader2':'Second-Correlation-ID'}" queryToCorrelationIdMapping="{'RelayState':'Correlation-ID'}"/> |
Change the log4j.appender.CORRELATION.layout.ConversionPattern appender in the log4j.properties file in the <IS_HOME>/repository/conf/ directory as follows. Code Block |
---|
log4j.appender.CORRELATION.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}|%X{Correlation-ID}|%X{Second-Correlation-ID}|%t|%m%n |
Restart the WSO2 IS server. Code Block |
---|
sh wso2server.sh -DenableCorrelationLogs=true stop
sh wso2server.sh -DenableCorrelationLogs=true start |
To send the authentication request, execute the following cURL command. Code Block |
---|
curl -v -k -X POST --basic -u <CLIENT_KEY>:<CLIENT_SECRET> -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -H "customHeader1:correlationvalue1" -H "customHeader2:correlationvalue2" -d "grant_type=client_credentials" https://localhost:9443/oauth2/token |
Tip |
---|
Use the client key and client secret of the service provider you created after enabling product observability |
Open the correlation.log on a command prompt and notice the related logs. Code Block |
---|
tail -f ../repository/logs/correlation.log |
|