Custom appender not identified in OSGi environment

2016-02-03 Thread Nipuni Piyabasi Perera
Hi, I have written a custom appender extending the log4j2 AbstractAppender. But I am getting a runtime error[1]. I have added the plugin annotation[2] as per the manual and the custom appender class contains factory method createAppender() as well. I also have added the package name to configurati

Re: Custom appender not identified in OSGi environment

2016-02-03 Thread Ralph Goers
OSGi does interesting things with ClassLoaders. Log4j has to be able to access your plugin when it is configuring. If it isn’t in an accessible ClassLoader it won’t see it. There have been a few people who are using Log4j in an OSGi environment that have helped out with patches from time to tim

Re: Custom appender not identified in OSGi environment

2016-02-03 Thread Nipuni Piyabasi Perera
Thanks for the prompt reply. I have first tried my custom appender in OSGi environment which gave the errors above. But I am getting the same issue in non-OSGi environment too. It seems an issue with custom appender. AFAIK It is plugin annotation that make the appender visible to log4j2. I can't f

Re: Custom appender not identified in OSGi environment

2016-02-03 Thread Nipuni Piyabasi Perera
Hi all, As I have mentioned in my first mail, the issue is only in the OSGi environment it seems. I had mistakenly added the appender as a OSGi bundle in the non-OSGi environment. Could resolve the issue after changing the package to a jar. Thanks, Nipuni On Wed, Feb 3, 2016 at 7:41 PM, Nipuni P

Re: Custom appender not identified in OSGi environment

2016-02-03 Thread Remko Popma
Thanks for confirming that. You may avoid the classloader issues by combining the log4j jars and your custom appender in a single jar. The only tricky part here is that you'd need to combine the serialized plugin listing files (see http://logging.apache.org/log4j/2.x/manual/plugins.html) fro

Re: Custom appender not identified in OSGi environment

2016-02-03 Thread Nipuni Piyabasi Perera
Hi, Thank you very much for the reply. Initially I got error [1] when I am trying to test the appender in non-OSGi environment. This was due to not passing the correct number of parameters to the factory method. I have updated my log4j2.xml and then could solve the issue[1] in non-OSGi env. I hav

Re: Custom appender not identified in OSGi environment

2016-02-04 Thread Nipuni Piyabasi Perera
Hi all, Above mentioned issue is reported and fixed in[1]. I have tried to use log4j2- 2.0.1 (as this is the fix version of the jira) in my OSGi environment. But I still see the same CLASS_NOT_FOUND error while it works fine in non-OSGi environment. [1] https://issues.apache.org/jira/browse/LOG4J

Re: Custom appender not identified in OSGi environment

2016-02-04 Thread Ralph Goers
I don’t believe that issue is related to your problem. When Log4j loads plugins it can only find plugins on whatever class path it has available to it. If it is in a different OSGi bundle than your plugin it may not see it. In short, Log4j has to be able to find META-INF/org/apache/logging/

Re: Custom appender not identified in OSGi environment

2016-02-04 Thread Ralph Goers
Actually, I just looked at the code and there is a class that should be looking at your bundle to locate any plugins you may have. I am actually not very familiar with that code so I wonder if one of the other committers could provide insight on what might be causing it not to work. Ralph > On

Re: Custom appender not identified in OSGi environment

2016-02-04 Thread Nipuni Piyabasi Perera
Thanks for the input. Yes the issue may be different than what I have mentioned. I suspected that the issue is related to Log4j2Plugins.dat file as the appender is working fine in non-OSGi environment, and the only different I could find was that Log4j2Plugins.dat file comparing the two jars. May

Re: Custom appender not identified in OSGi environment

2016-02-04 Thread Ralph Goers
I don’t think so. I suspect that org.apache.logging.log4j.core.osgi.Activator.java is not finding your plugin but I am not sure why. Ralph > On Feb 4, 2016, at 11:38 AM, Nipuni Piyabasi Perera > wrote: > > Thanks for the input. > > Yes the issue may be different than what I have mentioned.

Re: Custom appender not identified in OSGi environment

2016-02-05 Thread Matt Sicker
This sounds like it's probably a bug. Could you file an issue in jira? On 4 February 2016 at 12:42, Ralph Goers wrote: > I don’t think so. I suspect that > org.apache.logging.log4j.core.osgi.Activator.java is not finding your > plugin but I am not sure why. > > Ralph > > > On Feb 4, 2016, at 11:

Re: Custom appender not identified in OSGi environment

2016-02-05 Thread Nipuni Piyabasi Perera
Hi all, This was a class loading issue in my OSGi environment. We were using pax-logging 1.8.4 (which exports log4j2 2.0.2) and the class loader cannot load the package (package read from the log4j2.xml configuration) as the new bundle is not visible to the pax-logging bundle. Could resolve it af

Re: Custom appender not identified in OSGi environment

2016-02-05 Thread Matt Sicker
That sounds like a problem in pax-logging-log4j2 then. I wouldn't expect to have to do that. Could you file an issue for pax-logging? On 5 February 2016 at 10:44, Nipuni Piyabasi Perera wrote: > Hi all, > > This was a class loading issue in my OSGi environment. We were using > pax-logging 1.8.4

Re: Custom appender not identified in OSGi environment

2016-02-07 Thread Nipuni Piyabasi Perera
Hi Matt, I have posted this on ops4j group discussion.[1] [1] https://groups.google.com/forum/#!topic/ops4j/QvSOAmOrACg Thanks, Nipuni On Fri, Feb 5, 2016 at 10:39 PM, Matt Sicker wrote: > That sounds like a problem in pax-logging-log4j2 then. I wouldn't expect to > have to do that. Could you