top of page
Search
Tech Explore

WSO2 API Manager - Writing Gateway Wire Logs to Separate Log File

Updated: Dec 31, 2020

WSO2 API Manager Gateway has a feature to log incoming and outgoing HTTP/HTTPS requests and responses of the Server. This feature is called "Synapse Wire Logging".


Why do we need Synapse Wire Logging?

Logging synapse wire information will greatly help to troubleshoot issues with default mediation flow inside the API Gateway and any mediation logic inside the Gateway.


Enabling Synapse Wire logs will add a lot of additional log entries to the log files which makes them grow rapidly and fill up the disk space.


So, it is recommended to enabled the Synapse Wire logs only for the troubleshooting purposes as it heavily grows the log files. Need to be disabled after the troubleshooting.


Enabling the Synapse Wire Logs


By default when we enable the wire logs, the synapse wire information will be added to wso2carbon.log file residing in the "<APIM_HOME>/repository/logs/" directory.


Enabling wire logs in API Manager 3.1.0 and 3.0.0 is slightly different from APIM 2.x.x as from APIM-3.0.0 onwards consist of 'Log4j2'.


Please follow the steps below to enable synapse wire logs in API Manager 3.1.0,

  • Open the log4j2.properties found in the "<wso2am-3.1.0_home>/repository/conf/" directory.

  • Add the following lines to the file (if not exists),

With the above configurations, we have created a logger named "synapse-wire". We need to register "synapse-wire" as a logger.


  • Add the "synapse-wire" to the "loggers" section as below,

Changes to the "log4j2.properties" file is hot deployed, so there is no need for server restart after applying the above changes.


Once the changes are successfully applied you will have the following logline printed in the "wso2carbon.log" which indicates a successful application of log configurations,

INFO — LoggingUpdaterServiceComponent Logging configuration applied successfully

Now that we have seen how to configure "synapse-wire" logs to be written to the "wso2carbon.log" file, let's move on to our main topic of writing the synapse wire logs to a separate log file.


Writing Synapse Wire Logs to Separate Log file


Let's follow the below steps to write the "synapse-wire" debug logs to a separate log file named as synapse-wire.log file.


  • Open the log4j2.properties file found in the "<wso2am-3.1.0_home>/repository/conf/" directory.

  • Add a new Log Appender named "SYNAPSE_WIRE" to the "appenders" section as below,

  • Add the "SYNAPSE_WIRE" appender configurations as below,

Update the "synapse-wire" logger with the "SYNAPSE_WIRE" appender,

Update the "loggers" section by adding the "synapse-wire" logger as below,

The above changes will be hot deployed to the server, and the wire logs will be written to the "synapse-wire.log" file in the "<wso2am-3.1.0_home>/repository/logs/" directory.


References :


Thank you for reading.

Cheers!!!

100 views0 comments

ความคิดเห็น


Post: Blog2_Post
bottom of page