Yes, I am extending it from AppenderSkeleton. Following is the header file
that I am defining. 

Please let me know if you see any issues with this.

Thanks,
Ashfaq


#include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/class.h>
#include <tibems/tibems.h>

using namespace log4cxx;
using namespace log4cxx::helpers;

        class EMSAppender;
        typedef helpers::ObjectPtrT<EMSAppender> EMSAppenderPtr;

        class LOG4CXX_EXPORT EMSAppender : public AppenderSkeleton
        {
                                
                                public:
                                        DECLARE_LOG4CXX_OBJECT(EMSAppender)
                                        BEGIN_LOG4CXX_CAST_MAP()
                                                LOG4CXX_CAST_ENTRY(EMSAppender)
                                                
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
                                        END_LOG4CXX_CAST_MAP()

                                        EMSAppender();
                                
                        EMSAppender(const LogString& serverUrl, const 
LogString& queueName, 
                        const LogString& userName, const LogString& password);

                                        ~EMSAppender();
                                        
                                void append(const spi::LoggingEventPtr& event);
                        void append(const spi::LoggingEventPtr& event, 
log4cxx::helpers::Pool&
p);
                                
                                protected:
                                virtual bool checkEntryConditions() const;
                                
                                
                                public:
                                void close() { };

                                
                                protected:
                                
                                        void setOption(const LogString& option,
                                                const LogString& value);
                                
                                        tibemsConnection connection;
                                        tibemsSession      session;
                                        tibemsMsgProducer  msgProducer;
                                        tibemsDestination  destination;

                                        LogString serverUrl;
                                        LogString queueName;
                                        LogString userName;
                                        LogString password;

                                public:
                                        void 
activateOptions(log4cxx::helpers::Pool& /* pool */);
                                
                                protected:

                virtual void subAppend(const spi::LoggingEventPtr& event,
log4cxx::helpers::Pool& p);
                                
                                public:
                                        virtual bool requiresLayout() const { 
return true; }

                                        void setServerUrl(LogString serverUrl) 
{ serverUrl = serverUrl; };
                                        void setQueueName(LogString qn) { 
queueName = qn; };
                                        void setUserName (LogString un) { 
userName = un; };
                                        void setPassword (LogString pwd) { 
password = pwd; };

                                        LogString getServerUrl() { return 
serverUrl; }
                                        LogString getQueueName() { return 
queueName; }
                                        LogString getUserName() { return 
userName; }
                                        LogString getPassword() { return 
password; }
                                
                                /**
                                Clear internal references to the writer and 
other variables.
                                
                                  Subclasses can override this method for an 
alternate closing
                                behavior.  */

                                protected:
                                        virtual void reset();   
                                
                                };



carnold-3 wrote:
> 
> 
> On Dec 2, 2007, at 11:33 PM, Ashfaque wrote:
> 
>>
>> Hi,
>>
>> I am trying to add a custom appender using version 0.10.0 of  
>> log4cxx. But I
>> am receiving the following linker errors. Can anyone help me out in
>> resolving these errors?
>>
>> Error        25      error LNK2019: unresolved external symbol  
>> "__declspec(dllimport)
>> public: virtual bool __thiscall EMSAppender::instanceof(class
>> log4cxx::helpers::Class const &)const "
>> ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@log4cxx@@@Z)
>> referenced in function "[thunk]:public: virtual bool __thiscall
>> EMSAppender::instanceof`vtordisp{4294967292,0}' (class
>> log4cxx::helpers::Class const &)const "
>> ([EMAIL PROTECTED]@@ 
>> [EMAIL PROTECTED]@[EMAIL PROTECTED]@log4cxx@@@Z)
>> emsappender.obj      
>>
>> Error        26      error LNK2019: unresolved external symbol  
>> "__declspec(dllimport)
>> public: void __thiscall EMSAppender::`vbase destructor'(void)"
>> (__imp_??_DEMSAppender@@QAEXXZ) referenced in function "public:  
>> virtual void
>> * __thiscall EMSAppender::`scalar deleting destructor'(unsigned int)"
>> (??_GEMSAppender@@[EMAIL PROTECTED]) emsappender.obj 
>>
>>
>> Thanks,
>> Ashfaq
>>
> 
> 
> Could you provide more details on how you are defining EMSAppender.   
> The header file (or at least a sanitized edition) would be helpful.
> 
> The implementation of instanceof() is typically provided by the  
> END_LOG4CXX_CAST_MAP macro or inherited from a base class, such as  
> AppenderSkeleton.  Did you derive from AppenderSkeleton (either  
> directly or through another class such as WriterAppender)?  If not,  
> I'd recommend inheriting from AppenderSkeleton.
> 
> You could also try starting with an existing custom appender (like src/ 
> cpp/vectorappender.h and src/cpp/vectorappender.cpp) and see if you  
> can link it correctly and then modify it to match your EMSAppender.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/log4cxx-0.10.0---adding-a-custom-appender-tf4934464.html#a14124960
Sent from the Log4cxx - Users mailing list archive at Nabble.com.

Reply via email to