logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barak Simon" <barak.si...@db.com>
Subject Re: I degrade some softwares on my computer, and now I can build log4 cxx on Solaris 9 x86 now. But...
Date Wed, 20 Oct 2004 23:47:50 GMT

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


                                                                                         
                                                              
                      wxiong@lucent.com                                                  
                                                              
                                               To:       log4cxx-user@logging.apache.org 
                                                              
                      20/10/2004 20:03         cc:                                       
                                                              
                      Please respond to        Subject:  I degrade some softwares on my computer,
and now I can build log4       cxx on Solaris 9 x86   
                      log4cxx-user              now. But...                              
                                                              
                                                                                         
                                                              
                                                                                         
                                                              




Hello, everybody,
I degrade my automake from 1.9.2 to 1.6.3, and libtool from 1.5.10 to 1.4.3.
This time, I successfully build log4cxx-0.9.7 on Solaris 9 x86. (Although I
already build one by writing a makefile for it, ^_^.).
But when I build and run a demo program with it, I got the following error
message:

david@billdavid>log4cxxtest test.properties
You have tried to set a null level to root.
Segmentation Fault(coredump)

I have ever test the same program with the shared library built from my
makefile. It runs very well.
I find the above output message "You have tried to set a null level to root.
" in RootCategory.cpp. But I don't know what it means.
Can anybody give me some suggestion?

The following is my program:

#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;

LoggerPtr logger = Logger::getLogger(_T("MyApp"));

class Bar
{
 static log4cxx::LoggerPtr logger;

public:
 void doIt();
};


LoggerPtr 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
 {
  PropertyConfigurator::configure(argv[1]);

  logger->info(_T("Entering application."));
  Bar bar;
  bar.doIt();
  logger->info(_T("Exiting application."));

  LOG4CXX_DEBUG(logger, _T("error message"));
  LOG4CXX_LOG(logger, Level::INFO, _T("fatal message"));
 }
 catch(Exception&)
 {
  result = EXIT_FAILURE;
 }

 return result;
}

Regards,

Bill David
 2004.10.19




--

This e-mail may contain confidential and/or privileged information. If you are not the intended
recipient (or have received this e-mail in error) please notify the sender immediately and
destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.



Mime
View raw message