You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2024/03/22 15:37:06 UTC
[PR] Move `Recycler` to `log4j-kit` (logging-log4j2)
ppkarwasz opened a new pull request, #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400
This PR depends on #2396.
We move `Recycler` interface introduced in #1969 from `log4j-api` to `log4j-kit`.
Since the only current user of `Recycler` is Log4j Core 3.x, we removed the static recycler registry and replaced it with an entry in `DefaultBundle`.
This also closes #2106.
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400#discussion_r1537344241
##########
log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal/ThreadLocalRecyclerFactoryProvider.java:
##########
Review Comment:
This remark certainly merits its own discussion.
With the introduction of recyclers, we allow users to customize both the way events are created/recycled and transferred to another thread. Both customization points allow the usage of classical queues and ring buffers.
Without some hard performance data I am unable to guess, which combination gives the best result, so I created #2401 to discuss it.
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400#discussion_r1540850963
##########
log4j-api/src/main/java/org/apache/logging/log4j/spi/MessageFactory2Adapter.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.spi;
Review Comment:
Here I only cherry-picked an existent class from `2.x`, so the code keeps compiling after the removal of `log4j-api`.
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400#issuecomment-2017490303
> Since the only current user of `Recycler` is Log4j Core 3.x, we removed the static recycler registry and replaced it with an entry in `DefaultBundle`.
This is not correct. There are other modules besides `log4j-core` that use recyclers, for instance JTL.
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400#issuecomment-2017657169
> > Since the only current user of `Recycler` is Log4j Core 3.x, we removed the static recycler registry and replaced it with an entry in `DefaultBundle`.
>
> This is not correct. There are other modules besides `log4j-core` that use recyclers, for instance JTL.
What I meant is that only Log4j Core and its sub-modules use recyclers explicitly. Implementations such as `log4j-to-jul` and `log4j-to-slf4j` are based purely on `log4j-api`, so they will loose `Recycler` support after Log4j API 3.x is removed.
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400#discussion_r1537183163
##########
log4j-api/src/main/java/org/apache/logging/log4j/spi/MessageFactory2Adapter.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.spi;
+
+import java.util.Objects;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.MessageFactory;
+import org.apache.logging.log4j.message.MessageFactory2;
+import org.apache.logging.log4j.message.SimpleMessage;
+
+/**
+ * Adapts a legacy MessageFactory to the new MessageFactory2 interface.
+ *
+ * @since 2.6
Review Comment:
*Nit:* Could you be a little bit more attentive to the Javadoc formatting, please?
```suggestion
* Adapts a legacy {@link MessageFactory} to the new {@link MessageFactory2} interface.
*
* @since 2.24.0
```
##########
log4j-api/src/main/java/org/apache/logging/log4j/spi/MessageFactory2Adapter.java:
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.spi;
Review Comment:
Shouldn't this class be located in an `.internal.` package?
##########
log4j-kit/src/main/java/org/apache/logging/log4j/kit/recycler/internal/ThreadLocalRecyclerFactoryProvider.java:
##########
Review Comment:
@ppkarwasz, in our 1-1 discussion, we mentioned a `ThreadLocalRecycler` can suffer constant starvation when used in combination with async. logging. That is, instances get allocated at the call-site thread, released at the async. logger thread, and effectively leaving the call-site threads always out of recycled instances. Due to this caveat of its design, I am inclined to drop its support. Those who have extreme performance requirements, can reach out to either using the JCTools alternative or rolling out their own recycler. Though 99% of the users would be perfectly fine with the vanilla `QueueingRecycler` backed by an `ArrayBlockingQueue`.
##########
log4j-kit/src/test/java/org/apache/logging/log4j/kit/env/TestPropertyEnvironment.java:
##########
Review Comment:
Shouldn't this class be located in a `log4j-kit-test` artifact instead? I know, this implies moving `log4j-kit/src/test` to `log4j-kit-test/src/test`, but be it, just like `log4j-core-test` and `log4j-api-test`.
Could you also add some Javadoc, please?
--
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] Move `Recycler` to `log4j-kit` (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #2400:
URL: https://github.com/apache/logging-log4j2/pull/2400
--
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