You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by "Kadarkarai, Prabhakar (Prabhakar)" <pr...@avaya.com> on 2005/01/13 21:57:25 UTC

Custom Appender Question.

Hello All,

I would like to add my custom appender into log4cxx library. I have the
following MACRO in my custom appender header file.

 

namespace log4cxx

            namespace namespaceMSMQ

            {

                        class MSMQAPPENDER;

                        typedef helpers::ObjectPtrT<MSMQAPPENDER>
MSMQAPPENDERPtr;

            

                        class MSMQAPPENDER : public AppenderSkeleton

                        {

                                    public:

 
DECLARE_ABSTRACT_LOG4CXX_OBJECT(MSMQAPPENDER)

                                                BEGIN_LOG4CXX_CAST_MAP()

 
LOG4CXX_CAST_ENTRY(MSMQAPPENDER)

 
LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)

                                                END_LOG4CXX_CAST_MAP()

 

                                                MSMQAPPENDER();

                                                MSMQAPPENDER(const
LayoutPtr& layout);

                                                ~MSMQAPPENDER();

                        }

            }

}

 

My xml Configuration file looks like below.

            <?xml version="1.0" encoding="UTF-8" ?>

            <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

 

            <log4j:configuration  debug="true"
xmlns:log4j="http://jakarta.apache.org/log4j/">

              <appender name="Test"
class="org.apache.log4cxx.namespaceMSMQ.MSMQAPPENDER">

                <layout class="org.apache.log4j.SimpleLayout"/>

              </appender>

              <root>

                <priority value ="debug" />

                <appender-ref ref="Test" />

              </root>

            </log4j:configuration>

 

When I tried to configure the xml configuration file using
"DOMConfigurator::configureAndWatch(_T("../library/msmqlogging.xml"))"
it couldn't create the appender? Looks like it couldn't find the
appender name. Any help is greatly appreciated.

 

Thanks,

PK

 


Re: Custom Appender Question.

Posted by Curt Arnold <ca...@apache.org>.
This is a more appropriate questions for log4cxx-user, not log4cxx-dev.  
You might want to read  
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx- 
user@logging.apache.org&msgNo=649 where I was reply to someone who was  
having problems getting an custom appender recognized.

It is hard to diagnose your problem from just the header file. If you  
didn't have a IMPLEMENT_LOG4CXX_OBJECT macro, then your class would  
never get registered.

I would suggest starting with the tests/src/customlogger/*.cpp files  
and then step-by-step modify them to your objective. I do not know how  
log4cxx maps the Java class names in the configuration file to the C++  
class names.  I'd guess that it just compares the final element in the  
Java class name with the C++ class names and the Java package and C++  
namespaces are ignored. That said, I would avoid defining classes in  
the log4cxx namespace or making up class names in org.apache. Shouldn't  
cause any great harm, but it is good just to keep those for ASF use.