Hello All,

Thanks Jin.

Well now i think its more convenient to have the logging event itself at the
JMS receiving end.

So in my message driven bean when i get the logging event i

        Create an category instance for category JMSReceiver
        Fetch the message using event.getMessage
        Fetch the category of the message and concat the category and
message
        Fetch the string representation of Exception, if any using
event.getThrowableStrRep() and then create a instance of
        throwable
        Get the priority of the message and then call the appropriate method
with argument  : message, exception.


JMSReciever category  have attached RollingFileAppender and logs the message
in the file, with desired layout.


Regards
Naresh


----- Original Message -----
From: "Jin Zhao" <[EMAIL PROTECTED]>
To: "Naresh Sharma" <[EMAIL PROTECTED]>
Sent: Tuesday, October 23, 2001 10:07 AM
Subject: JMS Layout


> Hi Naresh,
>
> In the response to your post of subject "JMS Layout" on log4j-user
> list, I made several spelling mistakes which may cause confusions.
> The following is the corrected post. Also please post your final
> solution on the list.
>
>
============================================================================
=================
> 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#append(LoggingEvent).
> 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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to