Search This Blog

Thursday, July 11, 2013

An Axis2 Service to Log the incoming message

Java class is:

 package org.wso2.logservice;  
 import org.apache.commons.logging.Log;  
 import org.apache.commons.logging.LogFactory;  
 public class LogService{  
   private static final Log log = LogFactory.getLog(LogService.class);  
   public void LogAndDrop (String incoming) {     
     log.info("The message is: "+ incoming);  
   }  
   public String LogAndAck (String incoming) {  
     log.info("The message is: "+ incoming);  
     return "Logged: "+ incoming;  
   }  
 }  

Use this class and build an axis2 service.
Then you can deploy the service in WSO2 Application Server and invoke.

While invoking with a String value you will be able to notice that the message you sent will be logged in the wso2carbon.log as

 TID: [0] [AS] [2013-07-11 10:42:23,686] INFO {org.wso2.logservice.LogService} - The message is: Logging is what? Good ! {org.wso2.logservice.LogService}  
 TID: [0] [AS] [2013-07-11 10:42:37,993] INFO {org.wso2.logservice.LogService} - The message is: Logging and getting a response is what? Goood ! {org.wso2.logservice.LogService}  

No comments:

Post a Comment