logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Own Appenders
Date Tue, 18 Dec 2007 18:29:16 GMT

On Dec 14, 2007, at 2:33 AM, Johannes.Frank@kisters.de wrote:

> Hey there I want to modify the XMLSocketAppender to suit my needs.  
> What do I have to do in order to use it?
> Can I build it in it's own library like you can in JAVA and C#? And  
> if so, where do I have to put this library?
> How do I address it inside the log4cxx.properties?
> Thanx in advance,
> Johannes Frank

I'd be interested in knowing what modifications you'd like to make.   
If they would benefit the wider community, they could go in log4cxx  

You could put a custom appender anywhere you like, either in your  
application or shared library or in its own shared library.

The essential bit to use your custom appender is to trigger  
registration of your class before configuration.  The  
IMPLEMENT_LOG4CXX_OBJECT macro is typically sufficient to do that.

If you are logging in the constructors of static objects, you may need  
to force the order of initialization, either through calling your  
appender's static registerClass() method or by packaging your appender  
in a shared library since all the shared library static members will  
be initialized before the static members in your app that may be  

When parsing class names, log4cxx will attempt to match the full name  
from the configuration file before attempting to match just the final  
element following the last "." or "$".  So if your appender is  
something like:

class MyXMLSocketAppender : public XMLSocketAppender {

Then you could address it like:




src/test/cpp/vectorappender.h and .cpp is an example of a custom  
appender compiled into an application.

View raw message