Hi I am trying to write a custom appender following VectorAppender, here http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/vectorappender.h?view=co, as an example.
However, I am getting an error when calling my custom Appenders constructor: undefined reference to `log4cxx::VirtualAppender::VirtualAppender()' -- see below in red. I am not sure what is going on but guessing that I am not linking a library although I am linking log4cxx.a, apr-1.a, aprutil-1.a, xml2.a, expat.a. Is there another library to link when creating a Custom appender inherited from AppenderSkeleton? Below is the code snippet. Thanks in advance for any help. #ifndef VIRTUALAPPENDER_H_ #define VIRTUALAPPENDER_H_ #include <log4cxx/appenderskeleton.h> #include <log4cxx/spi/loggingevent.h> namespace log4cxx { class VirtualAppender : public AppenderSkeleton { public: DECLARE_LOG4CXX_OBJECT(VirtualAppender) BEGIN_LOG4CXX_CAST_MAP() LOG4CXX_CAST_ENTRY(VirtualAppender) LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton) END_LOG4CXX_CAST_MAP() VirtualAppender(); ~VirtualAppender(); /** This method is called by the AppenderSkeleton#doAppend method. */ void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) { LogString test = event->getMessage(); } void close(); bool isClosed() const { return closed; } bool requiresLayout() const { return false; } }; } #endif /* VIRTUALAPPENDER_H_ */ My app: #include <iostream> using namespace std; // include log4cxx header files. #include "log4cxx/logger.h" #include "log4cxx/basicconfigurator.h" #include "log4cxx/helpers/exception.h" #include "VirtualAppender.h" using namespace log4cxx; using namespace log4cxx::helpers; LoggerPtr logger(Logger::getLogger("MyApp")); int main() { cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! VirtualAppender * vAppender = new VirtualAppender(); // Error happens here logger->addAppender(vAppender); LOG4CXX_INFO(logger, "Entering application."); LOG4CXX_INFO(logger, "Exiting application."); return 0; }