Menu

#21 Support for dynamically loaded appender classes

open-accepted
None
5
2009-05-12
2003-10-24
No

I'm made a patch adding support for adding new appender
classes dynamically (as log4j will let you). I'm not
interested in modifying the sourcecode for log4cpp each
time I want to add a new appender (well, I guess I did
now though... ;) ).

I've just added a new class,
PropertyConfiguratorDynamic that extends
PropertyConfiguratorImpl, overloading the
instantiateAppender method.

Writing a new appender is just like writing an old one,
with one exception:

The new appender must define a function like this:

<pre>
extern "C" {
log4cpp::Appender* getInstance(const std::string
& name) {
log4cpp::Appender* a =
StatusBarAppender::getAppender(name);
return a;
}
}
</pre>

that is linked into the shared library (I put it in the
same file as the source of the class file for the
appender).

This function is used for instantiating an instance of
the appender class.

I've changed PropertyConfigurator to use
PropertyConfiguratorDynamic in stead of
PropertConfiguratorImpl. PCDynamic will call PCImpl if
it's unable to load the appender dynamically, so it's
backwards compatible.

Discussion

  • Eivind Tagseth

    Eivind Tagseth - 2003-10-24

    Add support for dunamically loaded appender classes.

     
  • Nobody/Anonymous

    Logged In: NO

    hi

     
  • darkangel

    darkangel - 2009-05-12

    The intent is great, but the way it done is not quite right, IMO. As part of related effort I added factories for layouts, appenders. Next will be replacing PropertyConfigurator to one that will relay on factories.

     
  • darkangel

    darkangel - 2009-05-12
    • assigned_to: nobody --> dark--angel
    • status: open --> open-accepted
     

Log in to post a comment.