/**
* This method called by {@link AppenderSkeleton#doAppend} method to do most
* of the real appending work.
*/
public void append(LoggingEvent event) {
if (!checkEntryConditions()) {
return;
}
try {
ObjectMessage msg = topicSession.createObjectMessage();
if (locationInfo) {
event.getLocationInformation();
}
msg.setObject(event);
topicPublisher.publish(msg);///////////////注意这一句//////////////
} catch (JMSException e) {
errorHandler.error("Could not publish message in JMSAppender [" + name + "].",
e, ErrorCode.GENERIC_FAILURE);
} catch (RuntimeException e) {
errorHandler.error("Could not publish message in JMSAppender [" + name + "].",
e, ErrorCode.GENERIC_FAILURE);
}
}
这里使用TopicPublisher.publish()方法,把序列化的消息发布出去。可见这也证明了JMSAppender只支持以Topic方式发送消息。
样例下载:
------------------------------------------分割线------------------------------------------
具体下载目录在 /2015年资料/12月/13日/Spring+Log4j+ActiveMQ实现远程记录日志——实战+分析/
------------------------------------------分割线------------------------------------------
推荐阅读:
Ubuntu下的ACTIVEMQ服务器
CentOS 6.5启动ActiveMQ报错解决