Skip to content

Commit

Permalink
Merge pull request #43 from Rajitha93/release_v2.1.0
Browse files Browse the repository at this point in the history
[ANLT-1109] - Add enable disable feature to log config file And edit readme
  • Loading branch information
wasanthawso2 authored Aug 31, 2020
2 parents b95c2d9 + e3d35e2 commit 629115a
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 272 deletions.
110 changes: 33 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version
=================
V 3.0

System Requirements
=================

Expand All @@ -7,90 +11,42 @@ System Requirements
Enable Request ID and Payload Logging
=====================================

With this new Log Extension
Mediator log Handler will log Request-In, Request-Out, Response-In, Response-Out messages

Follow below three steps for enabling request ID and payload logging

1) Apply logging-extension-2.0.2.jar to API Manager;
a) Copy and paste the 'logging-extension-2.0.2.jar' in to deployed api manager lib directory. (Patch source is available under "/wso2telcohub/repository/components/lib".)
b) Apply the logManagerConfig.xml (config/logManagerConfig.xml) file (located in conf folder to Gateway node <APIM>repository/conf)
1. Apply logging-extension-2.1.0 jar to AM/ESB;
a) Copy and paste the 'logging-extension-2.1.0.jar' in to deployed APIM/ESB lib directory. (Patch source is available under "{AM/ESB Home}/repository/components/lib".)
b) Copy the logExtensionConfigAM.xml/logExtensionConfigESB.xml according to your deployment and paste the file in conf folder located in <APIM/ESB>/repository/conf and rename the file to logExtensionConfig.xml


2) Enable Log4J properties for the newly installed feature
a) Open the log4j.properties file which is located in wso2telcohub/repository/conf folder
2. Enable Log4J properties for the newly installed feature
a) Open the log4j.properties file which is located in <APIM/ESB>/repository/conf folder.
b) Add below entries at the end of the file opened in step (a)

log4j.logger.com.wso2telco.logging=DEBUG

# The request response logger failed events when trying to publish events
#custom logger
log4j.logger.com.wso2telco.mediator.log.handler.SynapseLogHandler=DEBUG
# This works only with notifyEvent mediator
log4j.category.REQUEST_RESPONSE_LOGGER=INFO, REQUEST_RESPONSE_APPENDER
log4j.additivity.REQUEST_RESPONSE_LOGGER=false

# Appender config to REQUEST_RESPONSE_APPENDER
log4j.appender.REQUEST_RESPONSE_APPENDER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.REQUEST_RESPONSE_APPENDER.File=${carbon.home}/repository/logs/${instance.log}/request-response-logger${instance.log}.log
log4j.appender.REQUEST_RESPONSE_APPENDER.Append=true
log4j.appender.REQUEST_RESPONSE_APPENDER.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
log4j.appender.REQUEST_RESPONSE_APPENDER.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m %n
log4j.appender.REQUEST_RESPONSE_APPENDER.layout.TenantPattern=%U%@%D [%T] [%S]
log4j.appender.REQUEST_RESPONSE_APPENDER.threshold=DEBUG
log4j.category.AXP_ANALYTICS_LOGGER=INFO, AXP_ANALYTICS_APPENDER
log4j.additivity.AXP_ANALYTICS_LOGGER=false
# Appender config to AXP_ANALYTICS_APPENDER
log4j.appender.AXP_ANALYTICS_APPENDER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.AXP_ANALYTICS_APPENDER.File=${carbon.home}/repository/logs/${instance.log}/axp-analytics-logger${instance.log}.log
log4j.appender.AXP_ANALYTICS_APPENDER.Append=true
log4j.appender.AXP_ANALYTICS_APPENDER.layout=org.wso2.carbon.utils.logging.TenantAwarePatternLayout
log4j.appender.AXP_ANALYTICS_APPENDER.layout.ConversionPattern=[%d] %P%5p {%c} - %x %m %n
log4j.appender.AXP_ANALYTICS_APPENDER.layout.TenantPattern=%U%@%D [%T] [%S]
log4j.appender.AXP_ANALYTICS_APPENDER.threshold=DEBUG

c) Save the edited log4j.properties file.

3. Synapse changes for enabling Logging (Synapse Configurations files located at <APIM/ESB>/repository/conf/synapse-handlers.xml file);


3) Synapse changes for enabling Request ID and Payload Logging (Synapse Configurations files located at wso2telcohub/repository/deployment/server/synapse-configs/default/sequences);
a) If the request ID and the payload of a request needs to be logged for all APIs, then add the following two elements inside the sequence tag of WSO2AM-ExtIn.xml

<property name="message.type" scope="axis2" type="STRING" value="request"/>
<class name="com.wso2telco.logging.PropertyLogHandler"/>

b) If the request ID and the payload of the response from backend needs to be logged for All APIs, then add the following two elements inside the sequence tag of WSO2AMExt-Out.xml
<property name="message.type" scope="axis2" type="STRING" value="response"/>
<class name="com.wso2telco.logging.PropertyLogHandler"/>

c) If the request ID and the payload of the error response from backend needs to be logged for all APIs, then add the below two entries to _throttle_out_handler_.xml , _auth_failure_handler_.xml and fault.xml

<property name="message.type" scope="axis2" type="STRING" value="error"/>
<class name="com.wso2telco.logging.PropertyLogHandler"/>



Enable Payload body from registry
=================================

1) Log in to the G-Reg Management Console using the following URL and admin/admin credentials:https://<hostname>:9444/carbon/ and
go to _system/governance/apimgt

2) Click on "Add Resource" and select the "Create text contant" in Method

3) Please insert Name: payload.logging.enabled and Content :true and save


Enable Request,Response logging in ESB,EI
=========================================
(com.wso2telco.mediator.log.handler.SynapseLogHandler)


com.wso2telco.mediator.log.handler is handler which can used to log API transaction details in ESB/EI.

Please follow the steps below to configure the given jar in your environment.

1) build the repository and go to target folder
2) Copy Jar into <ESB_HOME>/repository/components/lib
3) Add the following configurations to <ESB_HOME>/repository/conf/synapse-handlers.xml file
```
<handlers>
<handler name = "SynapseLogHandler" class="com.wso2telco.mediator.log.handler.SynapseLogHandler"/>
</handlers>
```
4) Add the following configurations to <ESB_HOME>/repository/conf/log4j.properties
```
log4j.logger.com.wso2telco.mediator.log.handler.SynapseLogHandler=DEBUG
```
5) Start the server and create an API.
6) When you invoke the API, you will be able to see the logs successfully.


<handlers>
<handler name = "SynapseLogHandler" class="com.wso2telco.mediator.log.handler.SynapseLogHandler"/>
</handlers>

54 changes: 0 additions & 54 deletions config/esbLogManagerConfig.xml

This file was deleted.

27 changes: 18 additions & 9 deletions config/logManagerConfig.xml → config/logExtensionConfigAM.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<logManagerConfig>
<REQUEST_IN>
<logExtensionConfig>
<REQUEST_IN enabled="true">
<AM_MAPPING_ID>REQUEST_ID,MESSAGE_ID</AM_MAPPING_ID>
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>api.ut.api,MC</API_NAME>
Expand All @@ -13,10 +13,10 @@
<CONSUMER_KEY>api.ut.consumerKey,MC</CONSUMER_KEY>
<API_RESOURCE_PATH>REST_SUB_REQUEST_PATH,MC</API_RESOURCE_PATH>
<METHOD>api.ut.HTTP_METHOD,MC</METHOD>
<REMOTE_HOST>REMOTE_HOST,AX</REMOTE_HOST>
<BODY>BODY,RP</BODY>
<REMOTE_ADDR>REMOTE_ADDR,AX</REMOTE_ADDR>
</REQUEST_IN>
<REQUEST_OUT>
<REQUEST_OUT enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>api.ut.api,MC</API_NAME>
<SP_NAME>api.ut.userName,MC</SP_NAME>
Expand All @@ -30,7 +30,7 @@
<METHOD>api.ut.HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
</REQUEST_OUT>
<RESPONSE_IN>
<RESPONSE_IN enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>api.ut.api,MC</API_NAME>
<SP_NAME>api.ut.userName,MC</SP_NAME>
Expand All @@ -44,10 +44,19 @@
<METHOD>api.ut.HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
</RESPONSE_IN>
<RESPONSE_OUT>
<RESPONSE_OUT enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<HTTP_STATUS>HTTP_SC,AX</HTTP_STATUS>
<API_NAME>api.ut.api,MC</API_NAME>
<SP_NAME>api.ut.userName,MC</SP_NAME>
<API_PUBLISHER>api.ut.apiPublisher,MC</API_PUBLISHER>
<API_VERSION>SYNAPSE_REST_API_VERSION,MC</API_VERSION>
<API_CONTEXT>api.ut.context,MC</API_CONTEXT>
<APPLICATION_NAME>api.ut.application.name,MC</APPLICATION_NAME>
<APPLICATION_ID>api.ut.application.id,MC</APPLICATION_ID>
<CONSUMER_KEY>api.ut.consumerKey,MC</CONSUMER_KEY>
<API_RESOURCE_PATH>REST_SUB_REQUEST_PATH,MC</API_RESOURCE_PATH>
<METHOD>api.ut.HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
<HTTP_STATUS>HTTP_SC,AX</HTTP_STATUS>
</RESPONSE_OUT>

</logManagerConfig>
</logExtensionConfig>
62 changes: 62 additions & 0 deletions config/logExtensionConfigESB.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<logExtensionConfig>
<REQUEST_IN enabled="true">
<AM_MAPPING_ID>REQUEST_ID,MESSAGE_ID</AM_MAPPING_ID>
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>API_NAME,TH</API_NAME>
<SP_NAME>USER_ID,TH</SP_NAME>
<API_PUBLISHER>API_PUBLISHER,TH</API_PUBLISHER>
<API_VERSION>VERSION,TH</API_VERSION>
<API_CONTEXT>CONTEXT,TH</API_CONTEXT>
<APPLICATION_NAME>APPLICATION_NAME,TH</APPLICATION_NAME>
<APPLICATION_ID>APPLICATION_ID,TH</APPLICATION_ID>
<CONSUMER_KEY>CONSUMER_KEY,TH</CONSUMER_KEY>
<API_RESOURCE_PATH>RESOURCE,TH</API_RESOURCE_PATH>
<METHOD>HTTP_METHOD,TH</METHOD>
<BODY>BODY,RP</BODY>
<REMOTE_ADDR>REMOTE_ADDR,AX</REMOTE_ADDR>
</REQUEST_IN>
<REQUEST_OUT enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>API_NAME,MC</API_NAME>
<SP_NAME>USER_ID,MC</SP_NAME>
<API_PUBLISHER>API_PUBLISHER,MC</API_PUBLISHER>
<API_VERSION>VERSION,MC</API_VERSION>
<API_CONTEXT>CONTEXT,MC</API_CONTEXT>
<APPLICATION_NAME>APPLICATION_NAME,MC</APPLICATION_NAME>
<APPLICATION_ID>APPLICATION_ID,MC</APPLICATION_ID>
<CONSUMER_KEY>CONSUMER_KEY,MC</CONSUMER_KEY>
<API_RESOURCE_PATH>RESOURCE,MC</API_RESOURCE_PATH>
<METHOD>HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
</REQUEST_OUT>
<RESPONSE_IN enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>API_NAME,MC</API_NAME>
<SP_NAME>USER_ID,MC</SP_NAME>
<API_PUBLISHER>API_PUBLISHER,MC</API_PUBLISHER>
<API_VERSION>VERSION,MC</API_VERSION>
<API_CONTEXT>CONTEXT,MC</API_CONTEXT>
<APPLICATION_NAME>APPLICATION_NAME,MC</APPLICATION_NAME>
<APPLICATION_ID>APPLICATION_ID,MC</APPLICATION_ID>
<CONSUMER_KEY>CONSUMER_KEY,MC</CONSUMER_KEY>
<API_RESOURCE_PATH>RESOURCE,MC</API_RESOURCE_PATH>
<METHOD>HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
</RESPONSE_IN>
<RESPONSE_OUT enabled="true">
<API_REQUEST_ID>MESSAGE_ID,MC</API_REQUEST_ID>
<API_NAME>API_NAME,MC</API_NAME>
<SP_NAME>USER_ID,MC</SP_NAME>
<API_PUBLISHER>API_PUBLISHER,MC</API_PUBLISHER>
<API_VERSION>VERSION,MC</API_VERSION>
<API_CONTEXT>CONTEXT,MC</API_CONTEXT>
<APPLICATION_NAME>APPLICATION_NAME,MC</APPLICATION_NAME>
<APPLICATION_ID>APPLICATION_ID,MC</APPLICATION_ID>
<CONSUMER_KEY>CONSUMER_KEY,MC</CONSUMER_KEY>
<API_RESOURCE_PATH>RESOURCE,MC</API_RESOURCE_PATH>
<METHOD>HTTP_METHOD,MC</METHOD>
<BODY>BODY,RP</BODY>
<HTTP_STATUS>HTTP_SC,AX</HTTP_STATUS>
</RESPONSE_OUT>
</logExtensionConfig>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>com.wso2telco</groupId>
<artifactId>logging-extension</artifactId>
<name>logging-extension</name>
<version>2.1.0</version>
<version>3.0.0</version>
<packaging>bundle</packaging>
<dependencies>
<dependency>
Expand Down
Loading

0 comments on commit 629115a

Please sign in to comment.