logo       

Re: log4cxx-0.10.0 - adding a custom appender: msg#00002

Subject: Re: log4cxx-0.10.0 - adding a custom appender
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 "
>> (__imp_?instanceof@EMSAppender@@UBE_NABVClass@helpers@log4cxx@@@Z)
>> referenced in function "[thunk]:public: virtual bool __thiscall
>> EMSAppender::instanceof`vtordisp{4294967292,0}' (class
>> log4cxx::helpers::Class const &)const "
>> (?instanceof@EMSAppender@@ 
>> $4PPPPPPPM@A@BE_NABVClass@helpers@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@@UAEPAXI@Z) 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.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe