Please consider adding the capability to publish a text message via JMS.
When trying out the new Chainsaw, I was getting StreamCorruptedException.
I believe this was due to incompatible LoggingEvent serializations between
versions 1.2.x and 1.3
The event producer was using log4j 1.2.8. Chainsaw v2 is using 1.3alpha...
I intend to publish to a JMS topic using XMLLayout, but I suppose anything
would be reasonable.
Ultimately, the intent is for log messages to be published to a particular
JMS Topic. In addition to "normal" listeners that will archive the log
messages, I intend to use Mule to listen on the topic and transform and send
messages to Chainsaw, which will receive them on its XMLSocketReceiver.
I've included code for the JMS text appender I'm requesting. If it were
rolled into JMSAppender, that would be fine with me, too. In the v1.3
codebase, I noticed JMSReceiver. I haven't made an effort to include
TextMessage support in that, yet.
If I could have done all this a different way, let me know that, too.
Regards,
Michael Los
/**
* Publishes a LoggingEvent to a JMS topic as a
* JMS TextMessage. The message text is formatted
* according to the layout specified for the appender.
*
* @author <a href='[EMAIL PROTECTED]'>Michael Los</a> MITRE
*/
public class JMSTextAppender extends JMSAppender
{
/**
* Prepares and publishes the LoggingEvent to the JMS destination
* as a JMS Text message formatted with the configured Layout
*
* @see AppenderSkeleton#doAppend
* @param event event to be logged
*/
public void append(LoggingEvent event) {
if(!checkEntryConditions()) {
return;
}
try {
// topicSession is defined w/ package scope in JMSAppender
TextMessage msg = topicSession.createTextMessage();
// Ensure location information exists, if available
event.getLocationInformation();
msg.setText(layout.format(event));
topicPublisher.publish(msg);
} catch(Exception e) {
errorHandler.error("Could not publish message in JMSAppender
["+name+"].", e,
ErrorCode.GENERIC_FAILURE);
}
}
}
smime.p7s
Description: S/MIME cryptographic signature
