logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Custom appender not identified in OSGi environment
Date Wed, 03 Feb 2016 13:58:02 GMT
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 <nipuni880917@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: nipuni@wso2.com
> Git hub profile: https://github.com/nipuni
> Blog : http://nipunipererablog.blogspot.com/
> Mobile: +94 (71) 5626680



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message