logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: Logging in templates?: msg#00073

apache.logging.log4cxx.user

Subject: Re: Logging in templates?

I don't think the problem is unsurmountable, but I haven't tried it myself. I'm just freehanding the following code, but maybe it will help you get started and you can post back to the list what works for you.

I think you'd so something like:

template <class T> class Example {
Example() {}
void doSomething() {
LOG4CXX_DEBUG(getLogger(), "Hello, World");
}

private:
log4cxx::LoggerRef& getLogger() {
static log4cxx::LoggerRef logger(log4cxx::Logger::getLogger(
LOG4CXX_LOCATION.getClassName()));
return logger;
}
};

The code fragment depends on the LocationInfo class introduced after 0.9.7 to get the class name. The class name may be returned as "" for early Microsoft compilers ( _MSC_VER < 1300). Please feel free to enhance include/log4cxx/spi/location/locationinfo.h if your compiler can return class location but the macros don't handle it.


On Jan 30, 2005, at 10:51 AM, Daniel Einspanjer wrote:

Does no one else have a problem with needing to log messages from
templated classes? If anyone else has solved this problem, I would
very much like to hear your solution.

Thanks,
Daniel


On Thu, 20 Jan 2005 15:51:41 -0500, Daniel Einspanjer
<deinspanjer@xxxxxxxxx> wrote:
Could anyone share their methods for logging within a templated class?

Specifically, the problem I don't have a good solution for is the
static instantiation of a logger object at all, let alone one that has
a name giving the particular class for which the template is being
used.





<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

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

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo