On Dec 14, 2007, at 2:33 AM, [EMAIL PROTECTED] 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 itself.

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 logging.

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 {
    DECLARE_LOG4CXX_OBJECT(MyXMLSocketAppender)
   ...
};

Then you could address it like:

log4j.appender.A=MyXMLSocketAppender

or

log4j.appender.A=org.example.allthisisignored.MyXMLSocketAppender

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

Reply via email to