logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: Trying to extend LoggingEvent and Logger class
Date Wed, 14 Nov 2007 15:27:02 GMT

On Nov 14, 2007, at 1:20 AM, Kamdar, Devang ((MLITS)) wrote:

> 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?

The most significant change is that 0.9.7 could only support one  
character type defined at compile time.  Either all of your logging  
was done as char strings or wchar_t strings, but you could not mix  
them.  In log4cxx 0.10, the logging request methods are defined in  
both std::string and std::wstring forms.  Internal methods are  
defined in terms of LogString which is either std::string's  
containing UTF-8 (regardless of current encoding, default for Unix)  
or std::wstring (default for Windows).

Also, 0.9.7 made extensive use of non-local static variables which  
result in ordering issues on initialization and deinitiialization.   
Plus many years of other bug fixes.

log4cxx 0.10.0 attempts to remain source compatible with 0.9.7 client  
code, but not binary compatible and extensions are not source  
compatible.  The only major client code incompatibility is that  
Level::DEBUG and the like had to be removed since they caused  
initialization order problems.

> 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.

Both log4j and log4cxx have the concept of a mapped diagnostic  
context (MDC) which provides thread-local context values can be used  
to provide extended information in the logging event.  The abandoned  
log4j 1.3 effort also had the concept of LoggerRepository properties  
(similar to MDC values, but shared among all threads).  If you could  
satisfy your needs using the MDC or LoggerRepository properties,  
you'd have a lot less code that you'd need to hack.  If you needed  
LoggerRepo properties, you could at least experiment with MDC  
properties first and then you could contribute an implementation of  
LoggerRepo properties to benefit the group.

> 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
> correctly.

It should work, try it again when you jump to the SVN HEAD.

View raw message