Log4j Jakarta JMS Appender
The JMS Appender sends the formatted log event to a JMS Destination.
Dependency
You need to have the org.apache.logging.log4j:log4j-jakarta-jms
dependency in your classpath:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jakarta-jms</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
JMS Appender requires a |
Configuration
The JMS Appender requires JNDI support so as of release 2.15.1 and will not function unless |
Note that in Log4j 2.0, this Appender was split into a JMSQueueAppender
and a JMSTopicAppender
.
Starting in Log4j 2.1, these Appenders were combined into the JMS Appender, which makes no distinction between queues and topics.
However, configurations written for 2.0 which use the <JMSQueue/>
or <JMSTopic/>
elements will continue to work with the new <JMS/>
configuration element.
Parameter | Type | Default | Description |
---|---|---|---|
|
|
The name to locate in the This parameter is required. |
|
|
|
The fully qualified class name that should be used to define the initial If a This parameter is required. |
|
|
|
A Filter to determine if the event should be handled by this Appender.
More than one Filter may be used by using a |
|
|
|
The Layout to use to format the LogEvent. This parameter is required since |
|
|
|
The name of the Appender. This parameter is required. |
|
|
|
The password to use to create the JMS connection |
|
|
|
The URL of the provider to use as defined by This parameter is required. |
|
|
|
The name to use to locate the This parameter is required. |
|
|
|
The name of the identity of the Principal as specified by |
|
|
|
The security credentials for the principal as specified by |
|
|
|
|
Indicates if exceptions encountered while appending events to be internally logged and then ignored.
When set to |
|
|
|
When set to |
|
|
|
If set to a value greater than |
|
|
|
A colon-separated list of package prefixes for the class name of the factory class that will create a URL context factory as defined by |
|
|
|
The user ID used to create the JMS connection |
log4j.xml
demonstrating JMS Appender usage<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp">
<Appenders>
<JMS name="jmsQueue"
destinationBindingName="MyQueue"
factoryBindingName="MyQueueConnectionFactory">
<JsonTemplateLayout/>
</JMS>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="jmsQueue"/>
</Root>
</Loggers>
</Configuration>
Starting from version 2.9
, you can map your Log4j MapMessage
s to JMS javax.jms.MapMessage
s, set the Layout of the Appender to MessageLayout
with <MessageLayout/>
:
log4j.xml
demonstrating JMS Appender usage with MessageLayout
to translate MapMessage
s<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp">
<Appenders>
<JMS name="jmsQueue"
destinationBindingName="MyQueue"
factoryBindingName="MyQueueConnectionFactory">
<MessageLayout />
</JMS>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="jmsQueue"/>
</Root>
</Loggers>
</Configuration>