logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michaël CATANZARITI <mca...@free.fr>
Subject Re: You have tried to set a null level to root.
Date Tue, 25 May 2004 04:41:36 GMT
Lars,

I am wondering if I should not review the whole initialization of 
log4cxx for similar problems occur under MacOSX and HPUX.

Michaël

Lars Schouw wrote:

> Michaël
>  
> It works now. ;) Will this go into CVS?
>  
> Lars
>
> */Michaël_CATANZARITI <mcatan@free.fr>/* wrote:
>
>     Hello,
>
>     It seems the problem is related to the construction order of static
>     variables.
>
>     Visual C++ 7.1, constructs static variables in the declaration
>     order for
>     each source file, and in the link order of each obj file and
>     library for
>     a whole module.
>     So, the static variable used in the delayedloop example is
>     constructed
>     before the static variables declared in log4cxxs.lib (for the linker
>     parse delayedloop.obj first).
>     Accordingly, the static variables concerning levels, implemented in
>     level.cpp are initialized later. This is was the rootLogger level
>     seems
>     not to be set.
>
>     Please add the following lines on top of the files level.cpp and
>     logmanager.cpp :
>
>     // Force initialization early.
>     #pragma warning(disable: 4074)
>     #pragma warning(disable: 4073)
>     #pragma init_seg(lib)
>
>
>
>     The directive '#pragma init_seg(lib)' permits to force the static
>     variables implemented in its scope to be initialized first.
>
>     Michaël
>
>     Lennart Goedhart wrote:
>
>     >Yeah, I have the same problem if I try to use the static log4cxx
>     library.
>     >It's dumping at the point it's trying to assign the static
>     Bar::logger.
>     >It works fine if you use the log4cxx.lib (therefore the dll).
>     >As to why this is the case, that's a question for one of the log4cxx
>     >developers, I guess.
>     >
>     >----- Original Message -----
>     >From: "Lars Schouw"
>     >To: "Log4CXX User"
>     >Sent: Thursday, May 20, 2004 7:32 PM
>     >Subject: Re: You have tried to set a null level to root.
>     >
>     >
>     >
>     >
>     >>Lennart
>     >>
>     >>You are really a great help thank for always answering
>     >>so quick!
>     >>
>     >>It dumps before that it even gets to there!
>     >>
>     >>I took out the A2W here A2W(argv[1]); as well since
>     >>since my code is not unicode.
>     >>
>     >>I pass the following into the program as a startup
>     >>argument. config/LogSettings.txt
>     >>
>     >>Well I have this configuration file called
>     >>LogSettings.txt
>     >>
>     >># Set root logger level to DEBUG and its only appender
>     >>to A1.
>     >>log4j.rootLogger=DEBUG, A1
>     >>
>     >># A1 is set to be a ConsoleAppender.
>     >>log4j.appender.A1=org.apache.log4j.ConsoleAppender
>     >>
>     >># A1 uses PatternLayout.
>     >>log4j.appender.A1.layout=org.apache.log4j.PatternLayout
>     >>log4j.appender.A1.layout.ConversionPattern=%d [%t]
>     >>%-5p %c %x - %m (F:L)%n
>     >>
>     >>Also in the meanwhile I tried to setup the trivial
>     >>project replacing the code with the bar sample you
>     >>have in the documentation.
>     >>When I run it I get an error like before
>     >>You have tried to set a null level to root.
>     >>and in this case it runs down the sample code until
>     >>this line is called:
>     >>logger->info(_T("Entering application."));
>     >>where an exception is thrown.
>     >>In the console I get this.
>     >>First-chance exception at 0x77e73887 in trivial.exe:
>     >>Microsoft C++ exception:
>     >>log4cxx::helpers::RuntimeException @ 0x0012fddc.
>     >>Please be awair the the code is not the trivial.cpp
>     >>from your sample but the code from the documentation.
>     >>
>     >>Again I am using the static library I compiled myself.
>     >>
>     >>Also one more thing when I build I get some warnings.
>     >>They come from an error in the documentation;
>     >>#include ;
>     >>Should be without the last semicolon.
>     >>
>     >>
>     >>
>     >>
>     >>Regards
>     >>Lars Schouw
>     >>
>     >>--- Lennart Goedhart wrote:
>     >>
>     >>
>     >>>I assume you get this when you pass the arg of the
>     >>>config file. What does your config file look like?
>     >>>When I comile that snippet of your code (with a few
>     >>>minor changes), it works fine.
>     >>>I have he logfile I pass working with Conole,
>     >>>RollingFile and ODBC appenders...
>     >>> ----- Original Message -----
>     >>> From: Lars Schouw
>     >>> To: Log4CXX User
>     >>> Sent: Thursday, May 20, 2004 5:23 PM
>     >>> Subject: Re: You have tried to set a null level to
>     >>>root.
>     >>>
>     >>>
>     >>> Sorry forgot to tell that I also have a static
>     >>>variable declared in a header file
>     >>> static log4cxx::LoggerPtr logger;
>     >>>
>     >>>
>     >>>
>     >>> Lars Schouw wrote:
>     >>> I tried to add a configuration file to my
>     >>>project but
>     >>> when I run it I get this error:
>     >>> You have tried to set a null level to root.
>     >>> and an exception it thrown.
>     >>> This is before I even hit the main function so
>     >>>it must
>     >>> belong to the static variable I declared the is
>     >>> initialized when the object is loaded.
>     >>>
>     >>> My souce code:
>     >>>
>     >>> // include log4cxx header files.
>     >>> #include
>     >>> #include
>     >>> #include
>     >>> #include
>     >>>
>     >>> using namespace log4cxx;
>     >>> using namespace log4cxx::helpers;
>     >>>
>     >>> // Define a static logger variable so that it
>     >>> references the logger instance named "RALtest".
>     >>> LoggerPtr logger =
>     >>>Logger::getLogger(_T("RALtest"));
>     >>>
>     >>> int main(int argc, char* argv[])
>     >>> {
>     >>> int result = EXIT_SUCCESS;
>     >>> try
>     >>> {
>     >>> if (argc > 1)
>     >>> {
>     >>> USES_CONVERSION;
>     >>> String propertyFileName = argv[1];
>     >>>
>     >>>PropertyConfigurator::configure(propertyFileName);
>     >>> }
>     >>> else
>     >>> {
>     >>> BasicConfigurator::configure();
>     >>> }
>     >>>
>     >>> logger->info(_T("Entering RALtest
>     >>>application."));
>     >>> ....
>     >>>
>     >>> Lars
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>> __________________________________
>     >>> Do you Yahoo!?
>     >>> Yahoo! Domains - Claim yours for only
>     >>>$14.70/year
>     >>> http://smallbusiness.promotions.yahoo.com/offer
>     >>>
>     >>>
>     >>>
>     >>>
>     >>>
>     >>--------------------------------------------------------------------------
>     >>
>     >>
>     >----
>     >
>     >
>     >>> Do you Yahoo!?
>     >>> Yahoo! Domains - Claim yours for only $14.70/year
>     >>>
>     >>>
>     >>
>     >>
>     >>
>     >>__________________________________
>     >>Do you Yahoo!?
>     >>Yahoo! Domains - Claim yours for only $14.70/year
>     >>http://smallbusiness.promotions.yahoo.com/offer
>     >>
>     >>
>     >
>     >
>     >
>     >
>     >
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Friends. Fun. Try the all-new Yahoo! Messenger 
> <http://messenger.yahoo.com/> 



Mime
View raw message