You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Sunil Bapat <su...@gmail.com> on 2007/01/08 15:44:33 UTC

getLogger when using RepositorySelector

I read the log4j article regarding using RepositorySelector to create
distinct logger hierarchies for multiple web applications on the same
servlet container.


However in all the log4j examples, to prevent calling getLogger for
every logger call, the logger usage pattern is public class MyClass {
  final static Logger logger = Logger.getLogger("some.name");
 If MyClass is used by multiple web applications, the static variable
logger will not be valid for all usages. I will be a logger in just
one of the hierarchies.

What should the getLogger pattern be when using multiple hierachies.
Is there any alternative to calling getLogger for every call?

Thanks

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


Re: getLogger when using RepositorySelector

Posted by James Stauffer <st...@gmail.com>.
Make it an instance variable:
private Logger logger = Logger.getLogger(getClass().getName());

On 1/8/07, Sunil Bapat <su...@gmail.com> wrote:
> I read the log4j article regarding using RepositorySelector to create
> distinct logger hierarchies for multiple web applications on the same
> servlet container.
>
>
> However in all the log4j examples, to prevent calling getLogger for
> every logger call, the logger usage pattern is public class MyClass {
>   final static Logger logger = Logger.getLogger("some.name");
>  If MyClass is used by multiple web applications, the static variable
> logger will not be valid for all usages. I will be a logger in just
> one of the hierarchies.
>
> What should the getLogger pattern be when using multiple hierachies.
> Is there any alternative to calling getLogger for every call?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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