Return-Path: Delivered-To: apmail-jakarta-log4j-dev-archive@www.apache.org Received: (qmail 74315 invoked from network); 24 Oct 2003 15:31:39 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Oct 2003 15:31:39 -0000 Received: (qmail 64370 invoked by uid 500); 24 Oct 2003 15:31:31 -0000 Delivered-To: apmail-jakarta-log4j-dev-archive@jakarta.apache.org Received: (qmail 64340 invoked by uid 500); 24 Oct 2003 15:31:31 -0000 Mailing-List: contact log4j-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@jakarta.apache.org Received: (qmail 64325 invoked from network); 24 Oct 2003 15:31:30 -0000 Received: from unknown (HELO e3.ny.us.ibm.com) (32.97.182.103) by daedalus.apache.org with SMTP; 24 Oct 2003 15:31:30 -0000 Received: from northrelay02.pok.ibm.com (northrelay02.pok.ibm.com [9.56.224.150]) by e3.ny.us.ibm.com (8.12.10/8.12.2) with ESMTP id h9OFVWYJ151454 for ; Fri, 24 Oct 2003 11:31:32 -0400 Received: from d01ml074.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by northrelay02.pok.ibm.com (8.12.9/NCO/VER6.6) with ESMTP id h9OFVUgn173302 for ; Fri, 24 Oct 2003 11:31:31 -0400 To: log4j-dev@jakarta.apache.org MIME-Version: 1.0 Subject: JMSAppender and the onMessage Impl X-Mailer: Lotus Notes Release 5.0.11 July 24, 2002 Message-ID: From: Peter Cipriano Date: Fri, 24 Oct 2003 11:31:13 -0400 X-MIMETrack: Serialize by Router on D01ML074/01/M/IBM(Release 6.0.2CF2 V602CF2_HF2+ JCHN5R2GH7 JCHN5N2GS6 SSPW5RFPX6 JBUD5N6S4G |September 18, 2003) at 10/24/2003 11:31:31, Serialize complete at 10/24/2003 11:31:31 Content-Type: multipart/alternative; boundary="=_alternative 0055169C85256DC9_=" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --=_alternative 0055169C85256DC9_= Content-Type: text/plain; charset="us-ascii" I have a working log4j configuration for the File Appenders. With a bit of help from this newsgroup I got the most of the JMSAppender working using Websphere 5 with a MDB. log4j is moving the data to the Websphere embedded Queue (Topic) however when the onMessage impl of my MDB tried to convert the sent log4j message passed in I get a Class cast exception. The weird thing is if I use a straight topic call it works fine: String msg = "Test Message"; topicPublisher.publish(msg); Here is a code snipet. I have looked at other posts and have seen this type of usage. Not sure why I am different here public void onMessage(javax.jms.Message message) { try{ ... // Class Cast exception on the following line only from log4j TextMessage textMessage = null; textMessage = (TextMessage)message; if(printStream==null){ setPrintStream(getLogFileName()); } String msg = textMessage.getText(); if (!msg.equals("")){ printStream.println(msg); printStream.flush(); } }catch(JMSException e){ ... System.out.println(e.getLocalizedMessage()); } } # Log4j Properties #------------------ log4j.rootLogger= DEBUG, JMS1 log4j.appender.JMS1 = org.apache.log4j.net.JMSAppender log4j.appender.JMS1.TopicBindingName = jms/ESMTOPIC log4j.appender.JMS1.TopicConnectionFactoryBindingName = jms/ESMTCF log4j.appender.JMS1.layout = org.apache.log4j.PatternLayout log4j.appender.JMS1.layout.ConversionPattern = [%-20d{M/d/yy HH:mm:ss.sss z}] %-25t:%-5p %-30c - %m%n Right now I commented out the TestMessage lines and just log the actual object. I have to at least prove to the powers at be I am logging something. MS Message class: jms_object JMSType: null JMSDeliveryMode: 2 JMSExpiration: 0 JMSPriority: 4 JMSMessageID: ID:414d51205741535f6c6f63616c686f737e43993f20000a01 JMSTimestamp: 1067008958020 JMSCorrelationID:ID:414d51205741535f6c6f63616c686f737e43993f20000804 JMSDestination: topic://MYTOPIC?brokerVersion=1 JMSReplyTo: null JMSRedelivered: false JMS_IBM_PutDate:20031024 JMSXAppID:WAS_localhost_server1 JMS_IBM_Format: JMS_IBM_PutApplType:26 JMS_IBM_MsgType:8 JMSXUserID:Administrato JMS_IBM_PutTime:15223814 JMSXDeliveryCount:1 class org.apache.log4j.spi.LoggingEvent JMS Message class: jms_object JMSType: null JMSDeliveryMode: 2 JMSExpiration: 0 JMSPriority: 4 JMSMessageID: ID:414d51205741535f6c6f63616c686f737e43993f20000a03 JMSTimestamp: 1067008958200 JMSCorrelationID:ID:414d51205741535f6c6f63616c686f737e43993f20000804 JMSDestination: topic://MYTOPIC?brokerVersion=1 JMSReplyTo: null JMSRedelivered: false JMS_IBM_PutDate:20031024 JMSXAppID:WAS_localhost_server1 JMS_IBM_Format: JMS_IBM_PutApplType:26 JMS_IBM_MsgType:8 JMSXUserID:Administrato JMS_IBM_PutTime:15223821 JMSXDeliveryCount:1 class org.apache.log4j.spi.LoggingEvent Regards, Peter Cipriano Staff Software Engineer --=_alternative 0055169C85256DC9_= Content-Type: text/html; charset="us-ascii"
I have a working log4j configuration for the File Appenders.  With a bit of help from this newsgroup I got the most of the JMSAppender  working using Websphere 5 with a MDB.  log4j is moving the data to the Websphere embedded Queue (Topic) however when the onMessage impl of my MDB tried to convert the sent log4j message passed in I get a Class cast exception.

The weird thing is if I use a straight topic call it works fine:

String msg = "Test Message";
topicPublisher.publish(msg);

Here is a code snipet.  I have looked at other posts and have seen this type of usage. Not sure why I am different here

public void onMessage(javax.jms.Message message) {
                       
        try{
                ...
                // Class Cast exception on the following line only from log4j
                TextMessage textMessage = null;
                textMessage = (TextMessage)message;
                if(printStream==null){
                        setPrintStream(getLogFileName());
                }
                String msg = textMessage.getText();
                if (!msg.equals("")){
                        printStream.println(msg);
                        printStream.flush();
                }
                }catch(JMSException e){
                        ...
                        System.out.println(e.getLocalizedMessage());
                }
        }


# Log4j Properties
#------------------

log4j.rootLogger= DEBUG, JMS1

log4j.appender.JMS1                                                = org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName                        = jms/ESMTOPIC
log4j.appender.JMS1.TopicConnectionFactoryBindingName = jms/ESMTCF

log4j.appender.JMS1.layout                                = org.apache.log4j.PatternLayout
log4j.appender.JMS1.layout.ConversionPattern        = [%-20d{M/d/yy HH:mm:ss.sss z}] %-25t:%-5p %-30c - %m%n

Right now I commented out the TestMessage lines and just log the actual object. I have to at least prove to the powers at be I am logging something.

MS Message class: jms_object
  JMSType:         null
  JMSDeliveryMode: 2
  JMSExpiration:   0
  JMSPriority:     4
  JMSMessageID:    ID:414d51205741535f6c6f63616c686f737e43993f20000a01
  JMSTimestamp:    1067008958020
  JMSCorrelationID:ID:414d51205741535f6c6f63616c686f737e43993f20000804
  JMSDestination:  topic://MYTOPIC?brokerVersion=1
  JMSReplyTo:      null
  JMSRedelivered:  false
  JMS_IBM_PutDate:20031024
  JMSXAppID:WAS_localhost_server1      
  JMS_IBM_Format:        
  JMS_IBM_PutApplType:26
  JMS_IBM_MsgType:8
  JMSXUserID:Administrato
  JMS_IBM_PutTime:15223814
  JMSXDeliveryCount:1
class org.apache.log4j.spi.LoggingEvent

JMS Message class: jms_object
  JMSType:         null
  JMSDeliveryMode: 2
  JMSExpiration:   0
  JMSPriority:     4
  JMSMessageID:    ID:414d51205741535f6c6f63616c686f737e43993f20000a03
  JMSTimestamp:    1067008958200
  JMSCorrelationID:ID:414d51205741535f6c6f63616c686f737e43993f20000804
  JMSDestination:  topic://MYTOPIC?brokerVersion=1
  JMSReplyTo:      null
  JMSRedelivered:  false
  JMS_IBM_PutDate:20031024
  JMSXAppID:WAS_localhost_server1      
  JMS_IBM_Format:        
  JMS_IBM_PutApplType:26
  JMS_IBM_MsgType:8
  JMSXUserID:Administrato
  JMS_IBM_PutTime:15223821
  JMSXDeliveryCount:1
class org.apache.log4j.spi.LoggingEvent


Regards,

Peter Cipriano
Staff Software Engineer
--=_alternative 0055169C85256DC9_=--