Re: Using BasicContextSelector in OSGI application

2018-10-21 Thread Rob Gansevles
I have created a JIRA issue and a pull-request, see https://issues.apache.org/jira/browse/LOG4J2-2482 Rob On Sun, Oct 7, 2018 at 6:33 PM Ralph Goers wrote: > Yes please! If possible, please provide a test that would fail without the > change but works with it. > > Ralph > > > On Oct 7, 2018,

Re: Using BasicContextSelector in OSGI application

2018-10-07 Thread Ralph Goers
Yes please! If possible, please provide a test that would fail without the change but works with it. Ralph > On Oct 7, 2018, at 3:26 AM, Rob Gansevles wrote: > > Wrapping the LoaderUltil (log4j-api) calls in Loader (log4j-core) like > below does work, I can load classes in core when I replace

Re: Using BasicContextSelector in OSGI application

2018-10-07 Thread Rob Gansevles
Wrapping the LoaderUltil (log4j-api) calls in Loader (log4j-core) like below does work, I can load classes in core when I replace LoaderUtil.newCheckedInstanceOfProperty() with the proposed Loader.newCheckedInstanceOfProperty(), even when I remove all dependencies in log4j-api to log4j-core in

Re: Using BasicContextSelector in OSGI application

2018-10-05 Thread Ralph Goers
If you are explicitly passing around ClassLoaders then it would probably work correctly. But here we have Module B calling Module A to load a class in Module B using the default ClassLoader, which will be Module A’s ClassLoader. We are currently not passing ClassLoaders to LoaderUtil. Ralph >

Re: Using BasicContextSelector in OSGI application

2018-10-05 Thread Matt Sicker
Say module A calls a method in module B which provides a ClassLoader argument. Module A provides its own CL to module B. Then module B invokes load() from there. Does this mean module B is loading classes using its own CL (which doesn't make sense), or is it loading module A's classes on behalf of

Re: Using BasicContextSelector in OSGI application

2018-10-04 Thread Ralph Goers
Matt, I don’t think that makes a difference when running in OSGi. The problem is that core is calling API and asking it to load a core class. Unless it has access to the class it can’t do it. In OSGi it will only have access if log4j-core exposes it. Ralph > On Oct 4, 2018, at 9:01 AM, Matt

Re: Using BasicContextSelector in OSGI application

2018-10-04 Thread Matt Sicker
LoaderUtil is using the thread context class loader by default. If it's not set right, you can use of the methods there to specify the correct ClassLoader, or you can even push and pop TCCLs essentially. On Wed, 3 Oct 2018 at 16:46, Ralph Goers wrote: > Personally, I would rather duplicate the

Re: Using BasicContextSelector in OSGI application

2018-10-03 Thread Ralph Goers
Personally, I would rather duplicate the code, as much as it pains me to do that. Ralph > On Oct 3, 2018, at 1:37 PM, Rob Gansevles wrote: > > This patch is not effective in case of the BasicContextSelector because > package org.apache.logging.log4j.core.selector was not included in the >

Re: Using BasicContextSelector in OSGI application

2018-10-03 Thread Rob Gansevles
This patch is not effective in case of the BasicContextSelector because package org.apache.logging.log4j.core.selector was not included in the imports. Only org.apache.logging.log4j.core.osgi, org.apache.logging.log4j.core.util and org.apache.logging.log4j.core.async are includes as optional

Re: Using BasicContextSelector in OSGI application

2018-09-28 Thread Ralph Goers
Despite what I said below, it seems that the patch for LOG4J2-920 was applied over 2 years ago so this should not be happening with 2.11.1. Ralph > On Sep 28, 2018, at 10:34 AM, Ralph Goers wrote: > > It sounds related to LOG4J2-920 but the solution provided there has to be > incorrect.

Re: Using BasicContextSelector in OSGI application

2018-09-28 Thread Ralph Goers
It sounds related to LOG4J2-920 but the solution provided there has to be incorrect. There is no way the Log4j API should be declaring any requirements on Log4j Core stuff, especially since the Log4j API doesn’t have a clue what a ContextSelector is. That is only use by the Log4jContextFactory.

Re: Using BasicContextSelector in OSGI application

2018-09-28 Thread Rob Gansevles
Yes, that makes sense, but it seems they are still loaded by the log4j-api. I guess this is the reason there are a few optional import-package declarations in the manifest-generation in the pom for log4j-api: org.apache.felix maven-bundle-plugin

Re: Using BasicContextSelector in OSGI application

2018-09-28 Thread Ralph Goers
All ContextSelectors are part of log4j-core, not log4j-api. Ralph > On Sep 28, 2018, at 7:59 AM, Rob Gansevles wrote: > > Hi, > > I would like to use the BasicContextSelector in our OSGI application so > have a single global log4j connfiguration as described in >