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 Piyabasi Perera < nipuni880...@gmail.com> wrote: > 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 find any issue in my log4j2.xml and plugin configuration of the > class. Is there any other places that I need to care about? > > Thanks, > Nipuni > > On Wed, Feb 3, 2016 at 7:28 PM, Ralph Goers <ralph.go...@dslextreme.com> > wrote: > >> 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 >> time. Perhaps one of them can help out? >> >> Ralph >> >> > On Feb 3, 2016, at 6:07 AM, Nipuni Piyabasi Perera < >> nipuni880...@gmail.com> wrote: >> > >> > 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 >> > configuration element. >> > What am I missing here? Appreciate any input on this. >> > >> > I have my log4j2.xml file as below: >> > >> > <Configuration packages="org.my.custom.http.socket.appender"> >> > <Appenders> >> > ... >> > <Socket name="socket" host="localhost" port="4714"> >> > <!--PatternLayout pattern="[%d] %5p {%c} - %m%ex%n"/--> >> > </Socket> >> > <HTTPSocket name="HTTP_APPENDER" host="localhost" port="8888"> >> > <------------------------------------- >> > New Appender >> > </HTTPSocket> >> > </Appenders> >> > <Loggers> >> > <Root level="info" includeLocation="true"> >> > ... >> > <AppenderRef ref="HTTP_APPENDER"/> >> > </Root> >> > <Logger name="my.custom.deployer" level="info" additivity="true"> >> > <AppenderRef ref="socket"/> >> > </Logger> >> > </Loggers> >> > </Configuration> >> > >> > >> > [1] ERROR Appenders contains an invalid element or attribute >> "HTTPSocket" >> > [2] @Plugin(name = "HTTPSocket", category = "Core", elementType = >> "appender", >> > printObject = true) >> > >> > Thanks, >> > Nipuni >> > >> > -- >> > Nipuni Perera >> > Software Engineer; WSO2 Inc.; http://wso2.com >> > Email: nip...@wso2.com >> > Git hub profile: https://github.com/nipuni >> > Blog : http://nipunipererablog.blogspot.com/ >> > Mobile: +94 (71) 5626680 >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org >> For additional commands, e-mail: log4j-user-h...@logging.apache.org >> >> > > > -- > Nipuni Perera > Software Engineer; WSO2 Inc.; http://wso2.com > Email: nip...@wso2.com > Git hub profile: https://github.com/nipuni > Blog : http://nipunipererablog.blogspot.com/ > Mobile: +94 (71) 5626680 > -- Nipuni Perera Software Engineer; WSO2 Inc.; http://wso2.com Email: nip...@wso2.com Git hub profile: https://github.com/nipuni Blog : http://nipunipererablog.blogspot.com/ Mobile: +94 (71) 5626680