An open API service indexing awesome lists of open source software.

https://github.com/athiththan11/logger-handler

A Custom Logger Handler for WSO2 API Manager
https://github.com/athiththan11/logger-handler

extension handler wso2 wso2-api-manager

Last synced: 2 months ago
JSON representation

A Custom Logger Handler for WSO2 API Manager

Awesome Lists containing this project

README

        

# Logger Handler

A Custom Logger Handler for WSO2 API Manager to log the times when an API request comes through the `Gateway` component and responded out by the `Gateway` component.

## Build

Build the project by running ...

```shell
mvn clean install
```

## Deploy

After a successful build, copy the `custom-logger-handler-1.0-SNAPSHOT.jar` artifact from the `target` folder and paste it inside `/repository/components/lib` folder

And specify the deployed custom handler inside the Handlers section of your API synapse configuration file. You can find your `API Synapse Configurtions` inside the `/repository/deployment/server/synapse-configs/default/api` folder.

For this demo, I will choose `_TokenAPI_.xml` from the API Synapse Configuraitons folder, which will look as follows ...

```xml









60000
fault












```

Add our custom handler inside the `Handlers` section, which will result in ...

```xml



```

## Enable Log4J Property

Navigate and open the `/repository/conf/log4j.properties` file, and append the following line at the bottom

```properties
# enabling custom handler's logger
log4j.logger.com.sample.handlers.CustomLoggerHandler = DEBUG
```

## Run

Start your WSO2 API Manager server by executing the command from your `/bin` folder

```shell
# if linux or mac
sh wso2server.sh

# if windows
wso2server.bat
```

or

```shell
wso2am-2.6.0
```

## Test & Results

Assuming that you have published an API to the Store and generated `Access Token` for the related Application in the WSO2 API Manager Store Portal. Use the following cUrl command to invoke the `token` endpoint to generate a new access token

```cUrl
curl -k -d "grant_type=client_credentials" -H "Authorization: Basic " https:///token
```

After a successful execution, You can find the relative logs inside the console in which the WSO2 API Manager was started.

---

You can find more about Creating Custom Handlers for WSO2 API Manager in [here](https://docs.wso2.com/display/AM260/Writing+Custom+Handlers)