logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kamdar, Devang \(MLITS\)" <Devang_Kam...@ml.com>
Subject RE: Trying to extend LoggingEvent and Logger class
Date Wed, 14 Nov 2007 07:20:38 GMT
Thanks Curt for the reply.

To answer few of your questions:
1. I am using Visual Studio 2005
2. Yes I am working with 0.9.7 version.

But as suggested, I will try to play around with 0.10 version or the
SVN_HEAD version.
Just curious, 
What is the difference between the two? Or are they same?

Let me first explain, what I trying to do.
I am trying to extend log4cxx to include some additional fields in the
logger class itself.
So I am trying to build an "extended" library (that will have
application specific logic) that can be used by the user(application)
rather than using the log4cxx lib directly and building app specific
logging logic inside the application code.

Just curious,
Can I build a dll that can reference the log4cxx dll? So that I am
accessing the updated version of log4cxx always?
I tried doing the above method and faced lot of issues like linker
errors (unrecognized functions from log4cxx not getting resolved during
link time)

What I finally did was to include the source of log4cxx and build the
whole library as single dll along with my extensions, which worked

Devang Kamdar
MSR Production Support.
For Urgent MSR Issues - Please contact the Person on Call from the
schedule in the link below:

-----Original Message-----
From: Curt Arnold [mailto:carnold@apache.org] 
Sent: Tuesday, November 13, 2007 11:39 PM
To: Log4CXX User
Subject: Re: Trying to extend LoggingEvent and Logger class

On Nov 13, 2007, at 9:29 AM, Kamdar, Devang ((MLITS)) wrote:

> Hi,
> I have derived a class from Logger
> class ABCInternalLogger : public Logger
> I am trying to overload a Logger method - forcedLog()
> I am creating an event object of type LoggingEvent (parent)  
> pointing to ABCLogginEvent object.

Extending the logger class in log4j is problematic and discouraged.   
It wasn't prohibited, but it quickly becomes a pain.  It is generally  
much more effective in log4j to either encapsulate a logger or  
provide a utility class that operates on a logger than to extend the  
logger class itself.  I assume it only gets worse in log4cxx.

It would probably be better to discuss what capability you are trying  
to add and work from there.

> When I am calling with a constructor of ABCLoggingEvent, I am  
> getting following error (Visual Studio)
It would help if you specified the version of Visual Studio that you  
are using as they can be substantially different.

> Error 6 error C2665:  
> 'com::ml::mllog4cxx::MLLoggingEvent::MLLoggingEvent' : none of the  
> 4 overloads could convert all the argument types c:\Working 
> \abcinternallogger.cpp 66
> Below is the declararion in abcloggingevent.h file:
> MLLoggingEvent(string fqnOfCategoryClass, MLInternalLogger  
> category, Priority priority, ObjectPtrT<Object> message, string  
> mess_type, string sub_lev, string mess_id, string sess_id, string  
> tran_id, string opts[], Throwable throwable);
> Below is the code that call the ABCLoggingEvent constructor.
> void ABCInternalLogger::forcedLog (string fqn, Priority priority,  
> ObjectPtrT<Object> message, string mess_type, string sub_level,  
> string message_id, string session_id, string tran_id, string  
> optionals[], Throwable t)
> {
>     LoggingEvent event = ABCLoggingEvent(fqn, this, priority,  
> message, mess_type, sub_level, message_id, session_id, tran_id,  
> optionals, t);
>     callAppenders( event );
> }

Are you attempting to extend log4cxx 0.9.7?  Use of log4cxx 0.9.7 has  
been actively discouraged for new development for several years now  
and it should be clearly stated on the web site.  The log4cxx 0.9.7  
release predated the move to ASF.  It has been a long slog to get an  
ASF replacement release out and I've long made promises that I hope  
to finally fulfill.

If you are using the SVN HEAD, then you should not be using string as  
parameters, you should be using LogString (which is equivalent to  
std::wstring on Windows or std::string on Unix but where the char are  
interpreted as UTF-8 regardless of the current encoding).

> Can someone help me out here, if I am missign something?
> Also in general, If I am extending any of the components in  
> log4cxx, what is the significance of the MACROS defined in the  
> files like:
>     LOG4CXX_CAST_ENTRY(LoggingEvent)
> Do I need to declare the derived objects in the same fashion.

Those macros implement the cast() function that basically allows RTTI  
type functions (since RTTI is not supported on earlier compilers).    
This supports code like:

void foo(ObjectPtr someObj) {
LoggingEventPtr event = someObj;

If you omitted the cast map, then event would be null since it could  
not determine that the instance was of type LoggingEvent.

This message w/attachments (message) may be privileged, confidential or proprietary, and if
you are not an intended recipient, please notify the sender, do not use or share it and delete
it. Unless specifically indicated, this message is not an offer to sell or a solicitation
of any investment products or other financial product or service, an official confirmation
of any transaction, or an official statement of Merrill Lynch. Subject to applicable law,
Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems.
The laws of the country of each sender/recipient may impact the handling of EC, and EC may
be archived, supervised and produced in countries other than the country in which you are
located. This message cannot be guaranteed to be secure or error-free. This message is subject
to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging
with Merrill Lynch you consent to the foregoing.

View raw message