logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CONNER, BRENDAN \(SBCSI\)" <bc1...@att.com>
Subject RE: Using Layouts with JMSAppender
Date Tue, 07 Feb 2006 19:30:48 GMT
One other question: I noticed that LoggingEvent does not have a
timestamp that indicates when the event was logged.  I can get a
timestamp from the JMS message itself.  However, I was hoping that, if I
used both a FileAppender and JMSAppender, I would have access to a
single timestamp value that allowed me to match each message that was
queued with the corresponding message that was written to a file.

I'm assuming that there is no such single timestamp value, correct?  In
other words, the millisecond value in the timestamp that I get from the
JMS message is very likely going to be a little different than the
millsecond value in the timestamp that goes out to the file through the
FileAppender, correct?

- Brendan

-----Original Message-----
From: CONNER, BRENDAN (SBCSI) 
Sent: Tuesday, February 07, 2006 10:28 AM
To: Log4J Users List
Subject: RE: Using Layouts with JMSAppender


OK, thanks for your help.

I was under the apparent misconception that the layout formatted message
would be placed in the renderedMessage field of LoggingEvent before
serializing it.  But, through experimentation, it appears that
renderedMessage contains the same information as the message field.

- Brendan

-----Original Message-----
From: Paul Smith [mailto:psmith@aconex.com] 
Sent: Monday, February 06, 2006 7:12 PM
To: Log4J Users List
Subject: Re: Using Layouts with JMSAppender


the layout in your log4j.properties is irrelevant to JMSAppender,  
since it is sending the serialized version of the LoggingEvent.

In short, your MDB won't know what the layout is unless you tell it  
because that information is not sent along the wire during the JMS  
communication.

Paul


On 07/02/2006, at 11:47 AM, CONNER, BRENDAN (SBCSI) wrote:

> Right, we want to use JMSAppender to store our message in the DB.  But
> we may want to store the formatted version of the message in our
> database.  However, are you saying that the JMSAppender does not  
> handle
> calling Layout itself?  So does our MDB have to have access to our
> log4j.properties file and read it manually?  I'm hoping I'm missing
> something here.... ;-)
>
> - Brendan
>
> -----Original Message-----
> From: Paul Smith [mailto:psmith@aconex.com]
> Sent: Monday, February 06, 2006 6:40 PM
> To: Log4J Users List
> Subject: Re: Using Layouts with JMSAppender
>
>
> In your MDB, just have an instance of a Layout and format it then.
>
> Otherwise you don't want to use JMSAppender.  JMSAppender is about
> sending the binary contents of the LoggingEvent over JMS for some
> other reason (say, to view in a GUI, or store in a DB).
>
> Paul
> On 07/02/2006, at 11:36 AM, CONNER, BRENDAN (SBCSI) wrote:
>
>> I finally got the JMSAppender working, and I can receive the logged
>> message using a Message Driven Bean.  While working with my  
>> example, I
>> noticed that the message that is received by the onMessage()  
>> method is
>> an instance of ObjectMessage, which wraps an instance of  
>> LoggingEvent.
>> My question is:
>>
>> How can I retrieve a formatted version of the logged message, as
>> formatted by the layout given in my log4j.properties file?
>>
>> When I look at the string returned by LoggingEvent.getMessage(),  
>> it is
>> just the string that was logged by the code, not the formatted string
>> that should be the output of the Layout class.  Similarly, the string
>> returned by LoggingEvent.getRenderedMessage() is also just the string
>> that was logged by the code.
>>
>> Any help would be appreciated.  My log4j.properties file contains the
>> following entries:
>>
>> log4j.category.com.ibm.example.pubsub=DEBUG, JmsAppender
>>
>> log4j.appender.JmsAppender=org.apache.log4j.net.JMSAppender
>> log4j.appender.JmsAppender.topicConnectionFactoryBindingName=java:com

>> p
>
>> /e
>> nv/jms/PSExampleConnectionFactoryRef
>> log4j.appender.JmsAppender.topicBindingName=java:comp/env/jms/
>> PSExampleT
>> opicRef
>> log4j.appender.JmsAppender.layout=org.apache.log4j.PatternLayout
>> log4j.appender.JmsAppender.layout.ConversionPattern=%d [%-5p] (%t)  
>> %c:
>> %m%n
>>
>> - Brendan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message