You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "garydgregory (via GitHub)" <gi...@apache.org> on 2024/11/28 13:32:28 UTC
[PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
garydgregory opened a new pull request, #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247
Adds a Jakarta JMS Appender #2295
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1862337746
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsManager.java:
##########
@@ -0,0 +1,519 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
Review Comment:
Sure, I'll do that later but still in this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1874538435
##########
src/site/antora/modules/ROOT/pages/manual/appenders/message-queue.adoc:
##########
@@ -423,19 +423,21 @@ This example cannot be configured using Java properties.
[#JmsAppender]
== JMS Appender
-The JMS Appender sends the formatted log event to a
-https://jakarta.ee/specifications/messaging/2.0/[Jakarta Messaging API]
+The JMS Appender sends a formatted log event to a
+https://jakarta.ee/specifications/messaging/3.0/[Jakarta] or https://jakarta.ee/specifications/messaging/2.0/[Javax] Messaging API
destination.
[IMPORTANT]
====
As of Log4j `2.17.0` you need to enable the JMS Appender **explicitly** by setting the
xref:manual/systemproperties.adoc#log4j2.enableJndiJms[`log4j2.enableJndiJms`]
configuration property to `true`.
-
-Due to breaking changes in the underlying API, the JMS Appender cannot be used with Jakarta Messaging API 3.0 or later.
====
+For Jakarta, use the `JMS-Jakarta` element name in the `log4j-jakarta-jms` Maven module.
+
+For Javax, use the `JMS-Javax` element name; the names `JMS`, `JMSQueue`, and `JMSTopic` are provided for backward compatibility.
+
Review Comment:
The collapsible UI to too lame to use IMO. It's hard to tell how much is expanded, maybe if it expanded into something with a border it would help. I did not want to click on the "Click here" text because I did not want to leave the page.
The true uselessness of the collapsible thingy is that when you search for text on a page in a web browser (Firefox in my case), the browser does not find the text inside the collapsed text, so using the collapsible thingy an anti-pattern as implemented (IMO). Or maybe Firefox found it but you certainly don't see it.
The new site is hard enough to use without this kind of UI to make it worse 😞... IMO
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#issuecomment-2506190304
<table>
<tr>
<th>Job</th>
<th>Requested goals</th>
<th>Build Tool Version</th>
<th>Build Outcome</th>
<th>Build Scan®</th>
</tr>
<tr>
<td>build-macos-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:x:</td>
<td><a href="https://ge.apache.org/s/rcaaclzsohous" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
<tr>
<td>build-ubuntu-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:x:</td>
<td><a href="https://ge.apache.org/s/ykj2zl4tgq57k" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
<tr>
<td>build-windows-latest</td>
<td>clean install</td>
<td align='center'>3.9.8</td>
<td align='center'>:x:</td>
<td><a href="https://ge.apache.org/s/rfge4yn244r3m" rel="nofollow"><img src="https://img.shields.io/badge/Build%20Scan%C2%AE-PUBLISHED-06A0CE?logo=Gradle" alt="Build Scan PUBLISHED" /></a></td>
</tr>
</table>
###### Generated by gradle/develocity-actions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#issuecomment-2513204673
Hi @ppkarwasz and all: Ready for review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#issuecomment-2525309649
Merging after discussion with @ppkarwasz. Keep it simple and no need for an extra mechanism to detect javax vs jakarta implementations on the classpath.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1862339478
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
Review Comment:
I really don't want to do some service loader magic and finding this or that on the class path. I want to use the old or the new explicitly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1862241049
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsManager.java:
##########
@@ -0,0 +1,519 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
Review Comment:
Can we move this to a `log4j-jakarta-jms` artifact without adding new stuff to Log4j Core?
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
Review Comment:
I would prefer to have a single `JMS` plugin like we have for `SMTP`:
- We can have a single `JmsAppender` and multiple `JmsManager`s,
- The `JmsAppender.Builder.build()` method finds an implementation of `JmsManagerFactory` using `ServiceLoader`.
- If it finds nothing, the default Javax implementation is used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1873512740
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsManager.java:
##########
@@ -45,7 +45,10 @@
* JMS connection and session manager. Can be used to access MessageProducer, MessageConsumer, and Message objects
* involving a configured ConnectionFactory and Destination.
* </p>
+ *
+ * @deprecated Use {@code org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager}.
Review Comment:
Same here.
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/JmsAppender.java:
##########
@@ -37,11 +37,14 @@
import org.apache.logging.log4j.core.net.JndiManager;
/**
- * Generic JMS Appender plugin for both queues and topics. This Appender replaces the previous split ones. However,
- * configurations set up for the 2.0 version of the JMS appenders will still work.
+ * Javax JMS Appender plugin for both queues and topics. This Appender replaces the previous split classes.
+ * Configurations set up for the 2.0 version of the JMS appenders will still work.
+ *
+ * @deprecated Use {@code org.apache.logging.log4j.core.appender.mom.jakarta.JmsAppender}.
Review Comment:
The comment is no longer in sync with the class name.
##########
log4j-jakarta-jms/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
+
+ public static class Builder extends AbstractAppender.Builder<Builder>
+ implements org.apache.logging.log4j.core.util.Builder<JmsAppender> {
+
+ public static final int DEFAULT_RECONNECT_INTERVAL_MILLIS = 5000;
+
+ @PluginBuilderAttribute
+ private String factoryName;
+
+ @PluginBuilderAttribute
+ private String providerUrl;
+
+ @PluginBuilderAttribute
+ private String urlPkgPrefixes;
+
+ @PluginBuilderAttribute
+ private String securityPrincipalName;
+
+ @PluginBuilderAttribute(sensitive = true)
+ private String securityCredentials;
+
+ @PluginBuilderAttribute
+ @Required(message = "A javax.jms.ConnectionFactory JNDI name must be specified")
+ private String factoryBindingName;
+
+ @PluginBuilderAttribute
+ @PluginAliases({"queueBindingName", "topicBindingName"})
+ @Required(message = "A javax.jms.Destination JNDI name must be specified")
Review Comment:
```suggestion
@Required(message = "A jakarta.jms.Destination JNDI name must be specified")
```
##########
log4j-jakarta-jms/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
+
+ public static class Builder extends AbstractAppender.Builder<Builder>
Review Comment:
This has only a `private` constructor, so should be `final`.
##########
src/site/antora/modules/ROOT/pages/manual/appenders/message-queue.adoc:
##########
@@ -423,19 +423,21 @@ This example cannot be configured using Java properties.
[#JmsAppender]
== JMS Appender
-The JMS Appender sends the formatted log event to a
-https://jakarta.ee/specifications/messaging/2.0/[Jakarta Messaging API]
+The JMS Appender sends a formatted log event to a
+https://jakarta.ee/specifications/messaging/3.0/[Jakarta] or https://jakarta.ee/specifications/messaging/2.0/[Javax] Messaging API
destination.
[IMPORTANT]
====
As of Log4j `2.17.0` you need to enable the JMS Appender **explicitly** by setting the
xref:manual/systemproperties.adoc#log4j2.enableJndiJms[`log4j2.enableJndiJms`]
configuration property to `true`.
-
-Due to breaking changes in the underlying API, the JMS Appender cannot be used with Jakarta Messaging API 3.0 or later.
====
+For Jakarta, use the `JMS-Jakarta` element name in the `log4j-jakarta-jms` Maven module.
+
+For Javax, use the `JMS-Javax` element name; the names `JMS`, `JMSQueue`, and `JMSTopic` are provided for backward compatibility.
+
Review Comment:
I think we could use the same technique as with the Servlet Appender: document only the Jakarta version and add a collapsible paragraph "Click here if you are using Jakarta EE 8 or any version of Java EE" (see [Servlet Appender documentation](https://logging.apache.org/log4j/2.x/manual/appenders.html#ServletAppender)).
##########
log4j-jakarta-jms/pom.xml:
##########
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to you under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${revision}</version>
+ <relativePath>../log4j-parent</relativePath>
+ </parent>
+ <artifactId>log4j-jakarta-jms</artifactId>
+ <name>Apache Log4j Jakarta JMS</name>
+ <description>Apache Log4j Java Message Service (JMS), version for Jakarta.</description>
+ <properties>
+ <!-- This is a new module in 2.25.0, remove this property after the release. -->
+ <bnd.baseline.skip>true</bnd.baseline.skip>
+ <!-- OSGi and JPMS options -->
+ <bnd-module-name>org.apache.logging.log4j.jms</bnd-module-name>
Review Comment:
```suggestion
<bnd-module-name>org.apache.logging.log4j.jakarta.jms</bnd-module-name>
```
We have the convention `$groupId.$artifactId` with duplicate segments removed.
##########
log4j-jakarta-jms/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
+
+ public static class Builder extends AbstractAppender.Builder<Builder>
+ implements org.apache.logging.log4j.core.util.Builder<JmsAppender> {
+
+ public static final int DEFAULT_RECONNECT_INTERVAL_MILLIS = 5000;
+
+ @PluginBuilderAttribute
+ private String factoryName;
+
+ @PluginBuilderAttribute
+ private String providerUrl;
+
+ @PluginBuilderAttribute
+ private String urlPkgPrefixes;
+
+ @PluginBuilderAttribute
+ private String securityPrincipalName;
+
+ @PluginBuilderAttribute(sensitive = true)
+ private String securityCredentials;
+
+ @PluginBuilderAttribute
+ @Required(message = "A javax.jms.ConnectionFactory JNDI name must be specified")
Review Comment:
```suggestion
@Required(message = "A jakarta.jms.ConnectionFactory JNDI name must be specified")
```
##########
log4j-jakarta-jms/pom.xml:
##########
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to you under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${revision}</version>
+ <relativePath>../log4j-parent</relativePath>
+ </parent>
+ <artifactId>log4j-jakarta-jms</artifactId>
+ <name>Apache Log4j Jakarta JMS</name>
+ <description>Apache Log4j Java Message Service (JMS), version for Jakarta.</description>
+ <properties>
+ <!-- This is a new module in 2.25.0, remove this property after the release. -->
+ <bnd.baseline.skip>true</bnd.baseline.skip>
+ <!-- OSGi and JPMS options -->
+ <bnd-module-name>org.apache.logging.log4j.jms</bnd-module-name>
+ <Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>jakarta.jms</groupId>
+ <artifactId>jakarta.jms-api</artifactId>
+ <scope>provided</scope>
+ <optional>true</optional>
+ </dependency>
Review Comment:
Why is this `optional`? It is already `provided`.
##########
log4j-jakarta-jms/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
+
+ public static class Builder extends AbstractAppender.Builder<Builder>
+ implements org.apache.logging.log4j.core.util.Builder<JmsAppender> {
+
+ public static final int DEFAULT_RECONNECT_INTERVAL_MILLIS = 5000;
+
+ @PluginBuilderAttribute
+ private String factoryName;
+
+ @PluginBuilderAttribute
+ private String providerUrl;
+
+ @PluginBuilderAttribute
+ private String urlPkgPrefixes;
+
+ @PluginBuilderAttribute
+ private String securityPrincipalName;
+
+ @PluginBuilderAttribute(sensitive = true)
+ private String securityCredentials;
+
+ @PluginBuilderAttribute
+ @Required(message = "A javax.jms.ConnectionFactory JNDI name must be specified")
+ private String factoryBindingName;
+
+ @PluginBuilderAttribute
+ @PluginAliases({"queueBindingName", "topicBindingName"})
+ @Required(message = "A javax.jms.Destination JNDI name must be specified")
+ private String destinationBindingName;
+
+ @PluginBuilderAttribute
+ private String userName;
+
+ @PluginBuilderAttribute(sensitive = true)
+ private char[] password;
+
+ @PluginBuilderAttribute
+ private long reconnectIntervalMillis = DEFAULT_RECONNECT_INTERVAL_MILLIS;
+
+ @PluginBuilderAttribute
+ private boolean immediateFail;
+
+ // Programmatic access only for now.
+ private JmsManager jmsManager;
+
+ private Builder() {}
+
+ @SuppressWarnings("resource") // actualJmsManager and jndiManager are managed by the JmsAppender
+ @Override
+ public JmsAppender build() {
+ JmsManager actualJmsManager = jmsManager;
+ JmsManagerConfiguration configuration = null;
+ if (actualJmsManager == null) {
+ final Properties jndiProperties = JndiManager.createProperties(
+ factoryName, providerUrl, urlPkgPrefixes, securityPrincipalName, securityCredentials, null);
+ configuration = new JmsManagerConfiguration(
+ jndiProperties,
+ factoryBindingName,
+ destinationBindingName,
+ userName,
+ password,
+ immediateFail,
+ reconnectIntervalMillis);
+ actualJmsManager = AbstractManager.getManager(getName(), JmsManager.FACTORY, configuration);
+ }
+ if (actualJmsManager == null) {
+ // JmsManagerFactory has already logged an ERROR.
+ return null;
+ }
+ final Layout<? extends Serializable> layout = getLayout();
+ if (layout == null) {
+ LOGGER.error("No layout provided for JmsAppender");
+ return null;
+ }
+ try {
+ return new JmsAppender(
+ getName(), getFilter(), layout, isIgnoreExceptions(), getPropertyArray(), actualJmsManager);
+ } catch (final JMSException e) {
+ // Never happens since the ctor no longer actually throws a JMSException.
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public Builder setDestinationBindingName(final String destinationBindingName) {
+ this.destinationBindingName = destinationBindingName;
+ return this;
+ }
+
+ public Builder setFactoryBindingName(final String factoryBindingName) {
+ this.factoryBindingName = factoryBindingName;
+ return this;
+ }
+
+ public Builder setFactoryName(final String factoryName) {
+ this.factoryName = factoryName;
+ return this;
+ }
+
+ public Builder setImmediateFail(final boolean immediateFail) {
+ this.immediateFail = immediateFail;
+ return this;
+ }
+
+ public Builder setJmsManager(final JmsManager jmsManager) {
+ this.jmsManager = jmsManager;
+ return this;
+ }
+
+ public Builder setPassword(final char[] password) {
+ this.password = password;
+ return this;
+ }
+
+ public Builder setProviderUrl(final String providerUrl) {
+ this.providerUrl = providerUrl;
+ return this;
+ }
+
+ public Builder setReconnectIntervalMillis(final long reconnectIntervalMillis) {
+ this.reconnectIntervalMillis = reconnectIntervalMillis;
+ return this;
+ }
+
+ public Builder setSecurityCredentials(final String securityCredentials) {
+ this.securityCredentials = securityCredentials;
+ return this;
+ }
+
+ public Builder setSecurityPrincipalName(final String securityPrincipalName) {
+ this.securityPrincipalName = securityPrincipalName;
+ return this;
+ }
+
+ public Builder setUrlPkgPrefixes(final String urlPkgPrefixes) {
+ this.urlPkgPrefixes = urlPkgPrefixes;
+ return this;
+ }
+
+ public Builder setUserName(final String userName) {
+ this.userName = userName;
+ return this;
+ }
+
+ /**
+ * Does not include the password.
+ */
+ @Override
+ public String toString() {
+ return "Builder [name=" + getName() + ", factoryName=" + factoryName + ", providerUrl=" + providerUrl
+ + ", urlPkgPrefixes=" + urlPkgPrefixes + ", securityPrincipalName=" + securityPrincipalName
+ + ", securityCredentials=" + securityCredentials + ", factoryBindingName=" + factoryBindingName
+ + ", destinationBindingName=" + destinationBindingName + ", username=" + userName + ", layout="
+ + getLayout() + ", filter=" + getFilter() + ", ignoreExceptions=" + isIgnoreExceptions()
+ + ", jmsManager=" + jmsManager + "]";
+ }
+ }
+
+ @PluginBuilderFactory
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ private volatile JmsManager manager;
+
+ /**
+ * Constructs a new instance.
+ *
+ * @throws JMSException not thrown as of 2.9 but retained in the signature for compatibility, will be removed in 3.0
+ */
+ protected JmsAppender(
Review Comment:
```suggestion
private JmsAppender(
```
##########
log4j-jakarta-jms/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsAppender.java:
##########
@@ -0,0 +1,242 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
+
+import jakarta.jms.JMSException;
+import java.io.Serializable;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.appender.AbstractManager;
+import org.apache.logging.log4j.core.appender.mom.jakarta.JmsManager.JmsManagerConfiguration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAliases;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.net.JndiManager;
+
+/**
+ * Jakarta JMS Appender plugin for both queues and topics.
+ */
+@Plugin(name = "JMS-Jakarta", category = Node.CATEGORY, elementType = Appender.ELEMENT_TYPE, printObject = true)
+public class JmsAppender extends AbstractAppender {
Review Comment:
Why not `final`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#issuecomment-2525259755
> @garydgregory,
>
> Honestly I would prefer for the Jakarta JMS appender to work with the "JMS" name: as far as I understand now users need to change `JMS` to `JMS-Jakarta` in their Log4j Core 2 and to change from `JMS-Jakarta` back to `JMS` once they migrate to Log4j Core 3?
Hi @ppkarwasz
Ouch? For 2.x, reusing the "JMS" name will _force_ users to migrate from Javax to Jakarta, this is going to be a surprise hidden change and break existing configurations. I don't think we should do that.
The move to 3.x will require plenty of changes for non-trivial configurations IMO, especially when switching from Javax to Jakarta, adding this and that new Log4j modules that are now split out. So I'm OK with keeping the new name, supporting both styles, or renaming.
ATM, I am only concerns about an IRL 2.x use case for JMS and Jakarta. For 3.x we can do whatever.
WDYT?
>
> Another question that we might want to discuss is the reliance on JNDI: the `JmsManager` actually only needs a JMS `ConnectionFactory` and it really doesn't matter how this factory is obtained. To configure JMS we could proceed the same way as with JDBC:
>
> * The `JMS-Jakarta` plugin could have a nested `ConnectionFactoryProvider` element to specify how to obtain the `ConnectionFactory`.
>
> * We provide an implementation of the `ConnectionFactoryProvider` implementation that uses JNDI.
>
> * Third parties (e.g. ActiveMQ Artemis) could provide other `ConnectionFactoryProvider`. I know that Spring Boot doesn't use JNDI at all with Artemis (see [`ArtemisConnectionFactoryConfiguration`](https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisConnectionFactoryConfiguration.java)).
>
>
> What do you think? Of course if there are configuration differences between the Javax and Jakarta JMS appenders, the name change is justified.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add a Jakarta JMS Appender #2295 (logging-log4j2)
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #3247:
URL: https://github.com/apache/logging-log4j2/pull/3247#discussion_r1874534693
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/mom/jakarta/JmsManager.java:
##########
@@ -0,0 +1,519 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.appender.mom.jakarta;
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org