Configuring Custom Management Events  Locate

The configuration of WSO2 SOA Enablement Server management events is in serverconf.xml inside the <logEvents> element. You can add the configuration of your custom event there. In this case, your event type will be registered by the default Log4JAdapter. Example 1 shows the configuration of a custom event with event type MYE4100:

Example 1. Custom Event Configuration

<logEvents>
<eventListener>Log4JAdapter</eventListener>
.....
<event type="MYE4100">
<message>My event message with parameter. {0}.</message>
<severity>INFO</severity>
</event>
</logEvents>

Now you have to implement a custom event class whose event type will be same as the type in the event configuration. This can be achieved simply by extending the com.systinet.wasp.monitoring.events.WaspLogEvent class, which will give the same layout as default WSO2 SOA Enablement Server events have in logEvents.log, as shown below:

Example 2. Extending WaspLogEvent Class

public class MyLogEvent extends WaspLogEvent {
  // type of event
  public static final String TYPE = "MYE4100";

  public MyLogEvent(String parameter) {
    super(TYPE);

    // set up message parameters
    Object[] msgParams = new Object[] { parameter };
    setMessageParameters(msgParams);
  }
}

To fire the event use the following code:

EventManager.fireEvent(new MyLogEvent("Parameter value:10"))

After that the following log item should occur in logEvent.log:

<2003-07-31 10:36:27,469> - <ID1059640573180> <INFO> <MYE4100> 
 My event message with parameter. Parameter value:10.

The time, ID, severity and event type is generated automatically by the Log4JAdapter.