Saturday, April 23, 2016

How to create a custom log for a proxy service in WSO2 ESB

Log files are vital to identifying any associated errors, security threats and sequence of service execution while using WSO2 carbon products. Usually application and other service logs are write into server logs but if you want to have a separate log for a particular service, you just need to simply add few lines to file. So with that in mind I will explained how to create a customized log file for a particular proxy service using wso2 Enterprise Service Bus.

First open file ( /repository/conf/ ) and simply add the following entry.

log4j.appender.PROXY_APPENDER.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%

In here, 'TestLogProxy' is the name of the proxy service. You can define a location as the value for 'log4j.appender.PROXY_APPENDER.File' property. I have used default path for logs ( ${carbon.home}/repository/logs/) in here.

Then create a proxy service with log mediator ( log category – Info and log level – Full ) and add a send mediator with a service endpoint. You can see the customized log file under specified log path and logs for the 'TestLogProxy' will be logged in this file.

No comments:

Post a Comment