Configuring log component to log full comming message

Configuring log component to log full comming message

Dear Ortwin,

Could you tell me how we can configure the log component to log full comming message  ?

For example, our system receives OMP^O09 message but I only can see

Code:


********************************************************************************
* Message received in service: Log_1. Content is:                              *
* 'MSH|^~&|SPP|91-0030214KP|PhISCPS|90-1020104H|20100608162725|1003800|OMP^O0 *
* 9^OMP_O09|20100608162725|...[100 of 429]'                                    *
********************************************************************************

I want to see full log message in log file.

Thanks and best regards,
Dzung

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Configuring log component to log full comming message

Dear Dzung,

you are using the standard Mule log component for logging your message. Unfortunately with this component your message is always truncated to 100 characters.

Code:


package org.mule.component.simple;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mule.api.MuleEventContext;
import org.mule.api.component.simple.LogService;
import org.mule.api.construct.FlowConstruct;
import org.mule.api.lifecycle.Callable;
import org.mule.util.StringMessageUtils;

public class LogComponent
  implements Callable, LogService
{
  private static Log logger=LogFactory.getLog(LogComponent.class);

  public Object onCall(MuleEventContext context) throws Exception
  {
    String contents=context.getMessageAsString();
    String msg="Message received in service: " + context.getFlowConstruct().getName();
    msg=StringMessageUtils.getBoilerPlate(msg + ". Content is: '" + StringMessageUtils.truncate(contents, 100, true) + "'");

    log(msg);
    return context.getMessage();
  }

  public void log(String message)
  {
    logger.info(message);
  }

Thus you would have to overwrite the onCall() method of this component.

A better and more comfortable way would be to use a custom component instead and log the whole message from there:
/images/agorapro/attachments/68/mini_CustomLogComponent.png
I would use a standard Mule message as inbound and outbound message instead of a Saddle message.
Within this custom component you can simply log the whole message payload along with whatever you want.

best regards,
Ortwin

Administrator has disabled public posting. Please login or register in order to proceed.

Re: Configuring log component to log full comming message

Dear Ortwin,

Thank for your solution, actually I write the code in each component to transform input message to see full msg now. I will create customized log component.

Thanks and best regards,
Dzung

Administrator has disabled public posting. Please login or register in order to proceed.

Board Info

Board Stats
 
Total Topics:
119
Total Polls:
0
Total Posts:
800
User Info
 
Total Users:
955
Newest User:
egyenes
Members Online:
0
Guests Online:
2

Online: 
There are no members online