You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Paul Butcher <pa...@paulbutcher.com> on 2005/06/08 23:36:03 UTC

Bug with statically initialised loggers?

I believe that I have uncovered a bug with statically initialised loggers. It 
is my belief that it should be possible to initialise loggers in any order, 
statically or otherwise, and the inheritance hierarchy should "just work"? I 
believe that I have found an example where this is not the case. I am using 
g++ (GCC) 3.3.4 (pre 3.3.5 20040809) running on SUSE Linux 9.2.

Please forgive the length of this mail, but this is the simplest example I 
have been able to create which reproduces the problem. Everything works fine, 
for example, if I place everything in a single source file.

Given the following three source files:

logtest.cpp --------------------------------------------------------
#include <log4cxx/logger.h>
#include <log4cxx/propertyconfigurator.h>

using namespace log4cxx;

static LoggerPtr logger = Logger::getLogger("logtest");

void test1();
void test2();

int main()
{
  PropertyConfigurator::configure(File("log4j.configuration"));

  LOG4CXX_DEBUG(logger, "test");

  test1();
  test2();

  return 0;
}
--------------------------------------------------------

test1.cpp --------------------------------------------------------
#include <log4cxx/logger.h>

using namespace log4cxx;

static LoggerPtr logger = Logger::getLogger("logtest.test1");

void test1()
{
  LOG4CXX_DEBUG(logger, "test");
}
--------------------------------------------------------

test2.cpp --------------------------------------------------------
#include <log4cxx/logger.h>

using namespace log4cxx;

static LoggerPtr logger = Logger::getLogger("logtest.test2");

void test2()
{
  LOG4CXX_DEBUG(logger, "test");
}
--------------------------------------------------------

With the following log4j.configuration:

--------------------------------------------------------
log4j.rootLogger=DEBUG, A

log4j.appender.A=org.apache.ConsoleAppender
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-5p %c - %m %n
--------------------------------------------------------

I get the following output:

--------------------------------------------------------
DEBUG logtest - test
DEBUG logtest.test1 - test
DEBUG logtest.test2 - test
--------------------------------------------------------

Which I believe is correct. With the following log4j.configuration, however:

--------------------------------------------------------
log4j.rootLogger=DEBUG, A
log4j.logger.logtest=INFO

log4j.appender.A=org.apache.ConsoleAppender
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-5p %c - %m %n
--------------------------------------------------------

I get the following output:

--------------------------------------------------------
DEBUG logtest.test1 - test
--------------------------------------------------------

Which I do not believe to be correct.

Have I understood this correctly?

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

Re: Bug with statically initialised loggers?

Posted by Paul Butcher <pa...@paulbutcher.com>.
On Wednesday 15 June 2005 01:23, Curt Arnold wrote:
> Sorry, I was on the road last week (Apple WWDC) and am cramming for a
> project kick-off meeting tomorrow.  May be able to look at it before
> the end of the week unless someone else beats me to it.

No problem - just wanted to make sure that the bug report hadn't "fallen 
between the cracks" :-)

> Are you using the CVS HEAD or log4cxx-0.9.7?  If you are using
> log4cxx-0.9.7, could you try using the CVS HEAD?

I'm using the CVS HEAD (or at least what the CVS HEAD was a few weeks ago).

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

Re: Bug with statically initialised loggers?

Posted by Curt Arnold <ca...@apache.org>.
On Jun 14, 2005, at 6:52 PM, Paul Butcher wrote:


> Hi,
>
> I've not seen a response to the bug with statically initialised  
> loggers I
> reported last week. I'd be grateful if someone could at least  
> confirm that I
> haven't misunderstood what should happen?
>
>



Sorry, I was on the road last week (Apple WWDC) and am cramming for a  
project kick-off meeting tomorrow.  May be able to look at it before  
the end of the week unless someone else beats me to it.

Are you using the CVS HEAD or log4cxx-0.9.7?  If you are using  
log4cxx-0.9.7, could you try using the CVS HEAD?



Re: Bug with statically initialised loggers?

Posted by Paul Butcher <pa...@paulbutcher.com>.
Hi,

I've not seen a response to the bug with statically initialised loggers I 
reported last week. I'd be grateful if someone could at least confirm that I 
haven't misunderstood what should happen?

Very many thanks!

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

On Wednesday 08 June 2005 22:36, Paul Butcher wrote:
> I believe that I have uncovered a bug with statically initialised loggers.
> It is my belief that it should be possible to initialise loggers in any
> order, statically or otherwise, and the inheritance hierarchy should "just
> work"? I believe that I have found an example where this is not the case. I
> am using g++ (GCC) 3.3.4 (pre 3.3.5 20040809) running on SUSE Linux 9.2.
>
> Please forgive the length of this mail, but this is the simplest example I
> have been able to create which reproduces the problem. Everything works
> fine, for example, if I place everything in a single source file.
>
> Given the following three source files:
>
> logtest.cpp --------------------------------------------------------
> #include <log4cxx/logger.h>
> #include <log4cxx/propertyconfigurator.h>
>
> using namespace log4cxx;
>
> static LoggerPtr logger = Logger::getLogger("logtest");
>
> void test1();
> void test2();
>
> int main()
> {
>   PropertyConfigurator::configure(File("log4j.configuration"));
>
>   LOG4CXX_DEBUG(logger, "test");
>
>   test1();
>   test2();
>
>   return 0;
> }
> --------------------------------------------------------
>
> test1.cpp --------------------------------------------------------
> #include <log4cxx/logger.h>
>
> using namespace log4cxx;
>
> static LoggerPtr logger = Logger::getLogger("logtest.test1");
>
> void test1()
> {
>   LOG4CXX_DEBUG(logger, "test");
> }
> --------------------------------------------------------
>
> test2.cpp --------------------------------------------------------
> #include <log4cxx/logger.h>
>
> using namespace log4cxx;
>
> static LoggerPtr logger = Logger::getLogger("logtest.test2");
>
> void test2()
> {
>   LOG4CXX_DEBUG(logger, "test");
> }
> --------------------------------------------------------
>
> With the following log4j.configuration:
>
> --------------------------------------------------------
> log4j.rootLogger=DEBUG, A
>
> log4j.appender.A=org.apache.ConsoleAppender
> log4j.appender.A.layout=org.apache.log4j.PatternLayout
> log4j.appender.A.layout.ConversionPattern=%-5p %c - %m %n
> --------------------------------------------------------
>
> I get the following output:
>
> --------------------------------------------------------
> DEBUG logtest - test
> DEBUG logtest.test1 - test
> DEBUG logtest.test2 - test
> --------------------------------------------------------
>
> Which I believe is correct. With the following log4j.configuration,
> however:
>
> --------------------------------------------------------
> log4j.rootLogger=DEBUG, A
> log4j.logger.logtest=INFO
>
> log4j.appender.A=org.apache.ConsoleAppender
> log4j.appender.A.layout=org.apache.log4j.PatternLayout
> log4j.appender.A.layout.ConversionPattern=%-5p %c - %m %n
> --------------------------------------------------------
>
> I get the following output:
>
> --------------------------------------------------------
> DEBUG logtest.test1 - test
> --------------------------------------------------------
>
> Which I do not believe to be correct.
>
> Have I understood this correctly?
>
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?