Another way of logging information in a Rest API or a proxy is enabling the logging per API or proxy functionality, which will create a log file per API or proxy where all information logged is written.
To enable logging per API, we just need to configure the API_LOGGER category of the log4j.properties. We will assume that our rest API is called myFirstRestAPI. Then, we just follow these steps:
- Open $EI_HOME/conf/log4j.properties.
- Add the following section for the INFO level in the API_LOGGER category:
log4j.category.API_LOGGER=INFO, API_APPENDER log4j.additivity.API_LOGGER=false log4j.appender.API_APPENDER=org.apache.log4j.RollingFileAppender log4j.appender.API_APPENDER.File=${carbon.home}/repository/logs/${instance.log}/wso2-ei-api${instance.log}.log log4j.appender.API_APPENDER.MaxFileSize=1000KB log4j.appender.API_APPENDER.MaxBackupIndex...