|
|
Sponsor |
Re: SIGSEGV on log4cxx initialisation: msg#00045apache.logging.log4cxx.user
On Aug 27, 2004, at 3:27 AM, Tom Quarendon wrote: Right. So to make log4cxx work properly across multiple DLLs with all my C++... Is there a recommended way of doing this kind of stuff? Looks like we have the dreaded non-local static variable somewhere in log4cxx. The scenario is Item 47 in Effective C++. Any access to static variables within log4cxx needs to be down using local static variables so that initialization is forced to occur on first use. I haven't done a search and the following is a simplistic example. Unsafe: LogManager gLogManager; public LoggerPtr Logger::GetLogger(const char* name) { // gLogManager might not be initialized return gLogManager.GetLogger(name); } Safe: public LogManager& GetGlobalManager() { // initialization occurs first time through static LogManager gLogManager; return gLogManager; } public LoggerPtr Logger::GetLogger(const char* name) { return GetGlobalManager.GetLogger(name); } Until it is fixed in log4cxx, you could use the same trick in your code to force the call to getLogger to occur after all static initialization. class MyClass { private static LoggerPtr GetLogger() { static LoggerPtr myLogger = log4cxx::Logger::GetLogger("foo"); return myLogger; } public MyClass() { LOG4CXX_DEBUG(GetLogger(), "Constructor"); } };
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: SIGSEGV on log4cxx initialisation, Sven A . Schmidt |
|---|---|
| Next by Date: | RE: SIGSEGV on log4cxx initialisation, Stoyan Damov |
| Previous by Thread: | RE: SIGSEGV on log4cxx initialisation, Stoyan Damov |
| Next by Thread: | RE: SIGSEGV on log4cxx initialisation, Tom Quarendon |
| 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 |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|