Quoting Ceki G�lc� <[EMAIL PROTECTED]>:
> Jake,
>
> I see your point. Do you see anything wrong with the following?
>
The only problem I see with it is that this should be done inside
LogManager.setRepositorySelector() rather than in custom initialization code
beause we need to guarantee that selector.getLoggerRepository() never returns
null. We can't do that if we count on external initialization code to "do the
right thing". Otherwise, my changes would look similar to this. Inside
LogManager.setRepositorySelector(), I have something like (from memory)...
LoggerRepository currentDefaultRepository =
repositorySelector.getLoggerRepository();
newSelector.setDefaultRepository(currentDefaultRepository);
repositorySelector = newSelector;
All initialization code should have to worry about is simply call....
LogManger.setRepositorySelector(mySelector, new Object());
Jake
> void myInitialization() {
> // set the selector to MyRepositorySelector, preserving the
> // existing default repository:
> RepositorySelector mySelector = new MyRepositorySelector();
> // assume default selector is in currently in use
> LoggerRepository defaultRepository= LogManger.getLoggerRepository();
> mySelector.setDefaultRepository(defaultRepository);
> try {
> LogManger.setRepositorySelector(mySelector, new Object());
> } catch(IllegalArgumentException iae) {
> // the selector was already set
> }
> ...
> }
>
>
> At 05:20 PM 11/30/2004, Jacob Kjome wrote:
>
> >Well, the way things currently stand, as soon as you switch the repository
> >selector to the new one via LogManager.setRepositorySelector(), the
> >defaultLoggerRepository is null and will always be null because it is not
> >initialized to anything but null. As such, in the case of applications
> >running
> >under Tomcat, any that don't define the log4j/context-name JNDI parameter
> will
> >get the default repository, which is null, therefore necessarily causing
> null
> >pointer exceptions in LogManager.getLogger().
> >
> >My thought is to transfer the configured default repository from the
> original
> >selector to the new one being set. That way, you don't lose the original
> >configuration and loggers using the default repository will continue as they
> >did before the switch of selectors. I really think this is right and I am
> >100%
> >positive that there are problems with the current implementation.
> >
> >
> >Jake
>
> --
> Ceki G�lc�
>
> The complete log4j manual: http://qos.ch/eclm
> Professional log4j support: http://qos.ch/log4jSupport
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]