logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiong, Wei (Wei)" <wxi...@lucent.com>
Subject RE: I degrade some softwares on my computer, and now I can build log4cxx on Solaris 9 x86 now. But...
Date Thu, 21 Oct 2004 01:47:27 GMT
Thanks to Simon. Your suggestion is very reasonable and enlighten me about
the factor ignored by me.
I try to simplified my program like the following, but I still get the same
output information and the program crash at the same line with the same
backtrace:

#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/helpers/loglog.h>

using namespace log4cxx;
using namespace log4cxx::helpers;
using namespace log4cxx::xml;

class Bar
{
	log4cxx::LoggerPtr logger;

public:
	Bar();
	void doIt();
};

Bar::Bar()
{
	logger = Logger::getLogger(_T("MyApp"));
}

void Bar::doIt()
{
	logger->debug(_T("Did it again!"));
}

int main(int argc, char **argv)
{
	int result = EXIT_SUCCESS;

	try
	{
		DOMConfigurator::configure(argv[1]);
		
		Bar bar;
		bar.doIt();
	}
	catch(Exception&)
	{
		result = EXIT_FAILURE;
	}

	return result;
}

The following is the backtrace information:

(gdb) backtrace
#0  0xdd9fa8d7 in std::_Rb_tree<std::string, std::pair<std::string const,
std::s
tring>, std::_Select1st<std::pair<std::string const, std::string> >,
std::less<s
td::string>, std::allocator<std::pair<std::string const, std::string> >
>::find(
std::string const&) const (this=0x0, __k=@0xdda5db14) at stl_tree.h:496
#1  0xdd9b7eb4 in log4cxx::helpers::Properties::getProperty(std::string
const&)
const (this=0x8047b00, key=@0xdda5db14) at stl_map.h:513
#2  0xdd9bcd01 in
log4cxx::PropertyConfigurator::doConfigure(log4cxx::helpers::P
roperties&, log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggerRepository>&) (
   this=0x8047b50, properties=@0x8047b00, hierarchy=@0x8063394)
   at propertyconfigurator.cpp:149
#3  0xdd9bdc71 in log4cxx::PropertyConfigurator::doConfigure(std::string
const&,
log4cxx::helpers::ObjectPtrT<log4cxx::spi::LoggerRepository>&) (
   this=0x8047b50, configFileName=@0x8047c00, hierarchy=@0x8063394)
   at propertyconfigurator.cpp:119
#4  0xdd9be268 in log4cxx::PropertyConfigurator::configure(std::string
const&)
   (configFilename=@0x8047c00) at propertyconfigurator.cpp:124
#5  0x0805131b in main (argc=2, argv=0x8047c54) at log4cxxtest.cpp:49
(gdb)

Regards,

Bill David
2004.10.21


-----Original Message-----
From: Barak Simon [mailto:barak.simon@db.com]
Sent: Thursday, October 21, 2004 7:48 AM
To: log4cxx-user@logging.apache.org
Subject: Re: I degrade some softwares on my computer, and now I can build
log4 cxx on Solaris 9 x86 now. But...

Hi,
In my experience, the best way currently to avoid the problem you are having
is do lazy initialisation
when you use log4cxx statics to initialise your own statics/globals.
For instance, when I needed to use a constant LevelPtr (e.g. Level::ERROR),
I used instead the log4cxx Level enums (i.e. Level::ERROR_INT)
and converted it to the LevelPtr static when actually using the level inside
my class method. At that stage the Level statics are already initialised.

This is also relevant to your lines:
LoggerPtr logger = Logger::getLogger(_T("MyApp")); and
LoggerPtr Bar::logger = Logger::getLogger(_T("MyApp"));

For the second line, I suggest trying instead:
LoggerPtr Bar::logger; (setting to zero if possible)
and in the ctor initing it:
logger = Logger::getLogger(_T("MyApp"));

For the first line, you can do the same (without the ctor part), but add a
global access GetLogger() method
to first init the logger if not initialised yet, and then return it.
(assuming LoggerPtr can be
assigned a zero or some default value which can be checked)

Hope this helps,
Cheers,
Barak

PS - I am now going to try downgrading my automake and libtool to the
versions working
for you! Maybe at last autogen.sh will actually work for me.
________________________
Barak Simon
GED IT Core Platform
Deutsche Bank
190 George St. Sydney, 2000
Phone +61 2 925 85070
Fax      +61 2 925 95050

Mime
View raw message