|
|
Choosing A Webhost: |
Re: No Virtual Destructor for LoggingEvent: msg#00032apache.logging.log4cxx.user
On Dec 9, 2004, at 1:10 AM, Barak Simon wrote:
From a quick look at the log4j code, LoggingEvent's properties seem to be the combination of the MDC properties and the LoggerRepository properties. Could you explain why using the MDC is not workable? I don't have any experience with setting LoggerRepository properties, it seems be a recent (that is 1.3 series) addition to log4j. Is using that (instead of deriving from LoggingEvent) a feasible solution? How would this differ from using the MDC (thread-specific) or LoggerRepository properties (all threads) which already accomplish the same things?
There seem to be very few final classes in log4j proper (Chainsaw has many more), the ones that I saw were LoggingEventFieldResolver, RootCategory, RootLogger, ListAppender and ListModelAppender. Some classes (appenders, layouts) were intentionally designed for extension, others like LoggingEvent were not. I don't know the history why some classes that would seem good candidates to be final weren't made final. The point is that not being able to add your own customised fields, is, I think, limiting significantly what one can do. What type of information were you adding? Would any of them make good additions to the set of supported pattern expressions? But at that stage I can only use the data populated in LoggingEvent (or any other data which is more or less global in its nature). log4j 1.3 has added a sequence number, but I think I see problems with it and need to investigate further. If it makes sense and we can port it into log4cxx. If you are not multithreaded or are willing to establish a mutex for synchronization, you could pass info from your logging call site directly to your appender and/or layout. If you want info to flow through the dispatching pipeline, then the MDC and NDC are the established ways of "extending" the event information. If your information does change on every logging request, then you might consider adding your own macros that automatically manipulate the MDC or NDC. Something like: #define BARAK_DEBUG(logger, msg) \ if (logger->isDebugEnabled()) { \ log4cxx::MDC::set("whatever", getWhatever()); \ logger->forcedLog(log4cxx::Level::DEBUG, msg, __FILE__, __LINE__) Subsequent versions of logger.h will not redefine LOG4CXX_DEBUG etc, so you could define your own LOG4CXX_* macros before you include <log4cxx/logger.h>.
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: No Virtual Destructor for LoggingEvent, Barak Simon |
|---|---|
| Next by Date: | Can't create appender under Redhat Enterprise Server (k 2.4), brianw1138 |
| Previous by Thread: | Re: No Virtual Destructor for LoggingEvent, Barak Simon |
| Next by Thread: | Re: No Virtual Destructor for LoggingEvent, Barak Simon |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |