For users of Log4D, Habarisoft offers a JMS log appender which can be used to send log messages to a Apache ActiveMQ, JBoss HornetQ or OpenMQ open source message broker.

Adding a JMS appender is easy and requires only some lines of configuration. To define a JMS log appender with the name Jms1, add these lines to a log4d.properties file:

# Create a JMS appender
log4d.appender.Jms1=TLogJMSAppender
log4d.appender.Jms1.threshold=trace
log4d.appender.Jms1.logTopic=TOOL.DEFAULT
log4d.appender.Jms1.errorHandler=TLogOnlyOnceErrorHandler
log4d.appender.Jms1.layout=TLogPatternLayout
log4d.appender.Jms1.layout.pattern= %p | %d %c - %m%n
log4d.appender.Jms1.layout.dateFormat=hh:nn:ss.zzz

And include the new appender on the root level:

# Set root level
log4d.rootLogger=trace,Jms1

Then in the Delphi application, configure the logging framework as usual.

// configure Log4D
TLogPropertyConfigurator.Configure('log4d.props');

In this example, the log messages will be sent to a JMS destination with the name ‘TOOL.DEFAULT’. This will make testing easier since this is the default destination name for the ConsumerTool demo application in the Habari JMS Client distribution. To receive the messages using ConsumerTool, start it with this command line:

>ConsumerTool --topic

The –topic parameter tells the tool that the destination is a JMS Topic (default is Queue).

A simple GUI demo application (included) listens for messages on this topic and displays incoming messages in a memo field, see screenshot below.

Note that the following units are required in the application:

  • BTCommAdapterIndy or BTCommAdapterSynapse to register the default communication adapter
  • Log4D

The log appender is free for users of Habari JMS Client libraries, including full source code.


Discover more from Habarisoft Blog

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *