>>Hello Everybody,

>> Isn't it possible to have JMSAppender with PatternLayout?? ...  
>>I am using Message-Driven bean for getting the JMS messages instead of
JMSSink. But i find that it gives me only the message not the formatted
message(according to >>conversion pattern), i was in impression that Layout
can be used with JMS.  
  
>>Any workaround ?? 
>> Thanks 
>> Naresh 

You should get a LoggingEvent object from the JMSAppender. You can get all
serialized fields from it, including NDC, priority, thread name etc,
according to you layout pattern. If you are really expecting a layout
formatted string, you need to overwrite the JMSAppender#appender(Event).
Something like the following code block: 
================================================================ 
  public 

  void append(LoggingEvent event) { 

    if(!checkEntryConditions()) { 

      return; 

    } 




    try { 

       
      // Here you format the event before embed it into a JMS Message object

      // You can also use a TextMessage instead of ObjectMessage 
      // TextMessage msg = topicSeesion.createTextMessage(); 
      // msg.setText(this.layout.format(event)); 
      ObjectMessage msg = topicSession.createObjectMessage(); 
      msg.setObject(this.layout.format(event)); 
  
      topicPublisher.publish(msg); 

    } catch(Exception e) { 

      errorHandler.error("Could not publish message in JMSAppender
["+name+"].", e,  

                         ErrorCode.GENERIC_FAILURE); 

    } 

  } 

================================================================ 

On the receiver side, you can extract the layout formatted string using the
following block 
================================================================= 
String loggings = (String)((ObjectMessage)message).getObject()); 
// or String loggings = ((TextMessage)message).getText()); 
================================================================= 

If you tried it, please tell us the result. 

Thanx, 


Jin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to