logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Re: Specify Repository
Date Wed, 09 Apr 2008 21:52:13 GMT
Your repository selector selects the repository.  You set the repository 
selector by calling LogManager.setRepositorySelector(selector, guard).  Note 
that the guard is provided so that if someone else comes along a tries to 
reset it, they will get an IllegalArgumentException and be prevented from 
overriding the initial setting.  This is because the selector is global to the 
Log4j instance.  Repository selector setting is meant to be done at 
application startup.  When running inside an application server, it should, 
ideally, be set by the server.  However, if you are the only app to use it, 
you could have a servlet context listener do this upon application startup.

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/LogManager.html#setRepositorySelector(org.apache.log4j.spi.RepositorySelector,%20java.lang.Object)

As you can see, this has nothing to do with logger statements.  Your code 
doesn't have to change in order to use a repository selector.

Jake

On Wed, 09 Apr 2008 11:58:53 -0400
  "Robert Pepersack" <RPepersack@mdinsurance.state.md.us> wrote:
> I've checked the archives and didn't find an answer, but please forgive me 
>if this a duplicate post.
> 
> I would like to be able to specify a repository for my logger to use.  For 
>example:  Logger logger = new Logger("my.class.name", "myRepositoryName");
> 
> I read Chapter 8, "Extending log4j", and it said that subclassing Logger is 
>a bad idea.  I don't see a way to accomplish what I want by wrapping Logger. 
> So, I think, that the only way to do it would be to tweak a few of the log4j 
>classes (i.e. Logger, LogManager, RepositorySelector, and 
>DefaultRepositorySelector).  Would anyone be interested in this, or am I 
>barking up the wrong tree?  I realize that this could open a can of worms 
>with a lot of repositories getting created, but, if we're carful, this could 
>be very useful.
> 
> Thanks,
> 
> Robert Pepersack
> Senior Lead Developer
> Maryland Insurance Administration
> 410-468-2054
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message