Hi all!

I have this scenario:

I have wrapped the Logger class into a class of my own (because I will need
to do some formatting of messages to be logged):

public class SBLogger
{
        private Logger logger;

        public SBLogger(String name)
        {
                logger = Logger.getLogger(name);
        }
...
}

Next I have a class A which has a static SBLogger and a member of type class
B. B in turn also has a static SBLogger:

public class A
{
        private static SBLogger logger = new SBLogger("A");
        private B b = new B();
...
}

public class B
{
        private static SBLogger logger = new SBLogger("B");
...
}

With this setup, I would like to configure my SBLoggers using a configuation
file. It turns out that the system is very sensitive as regards SBLogger
"B". Mainly, the system complains like this when I run the application:

log4j:WARN No appenders could be found for logger (B).
log4j:WARN Please initialize the log4j system properly.

The configuration file asks for 2 appenders like this

log4j.rootLogger=DEBUG, stdout, A1

where stdout goes to the console and A1 goes to a FileAppender.

After some experimentation I think the problem has to do with exactly WHEN
the log system gets configured. Everything seems to be allright if I make
the PropertyConfigurator.configure call in a static initializer of the
SBLogger, but other solutions in which the configuration is supposed to take
place in advance of any calls of getLogger do NOT work.

So my quesions are:

Does it matter if configuration is made AFTER getLogger calls? (Of course,
config must be done before actual logging).
Do you know any resources on this matter (besides studying the source of
log4j i detail)?

Any suggestions are welcome!

Kind regards - Niels.




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to