You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Simon Kitching <sk...@apache.org> on 2006/03/08 04:50:05 UTC

commons-logging and static log members

Hi All,

Recently there was a discussion on the MyFaces list regarding the use of
the following pattern with commons logging classes:
  private static Log log = LogFactory.getLog(Foo.class)

It was pointed out that the use of static here is a really bad idea for
any code that may be deployed via a shared classloader in a container.
Craig McClanahan indicated that this (anti-)pattern was in use in struts
code and that the issue should be pointed out here.

I haven't personally checked whether this usage *is* present in the
current struts codebase. Neither do I know whether struts jarfiles are
expected to be deployed in shared classpaths (it's definitely true for
MyFaces).

More information on this issue can be found here:
 http://wiki.apache.org/jakarta-commons/Logging/StaticLog

Regards,

Simon (commons-logging committer)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: commons-logging and static log members

Posted by Eddie O'Neil <ek...@gmail.com>.
  +1.  I agree that it would be nice to avoid this and remove the
dependence on static loggers in all of the classes.  In the places
where we provide containment of source artifacts, it's also something
we could even just inject or provide via a Context object.

This is something that other projects have started dealing with;
Jeremy had a good description of how they handled this in Tuscany
here:

http://mail-archives.apache.org/mod_mbox/ws-tuscany-dev/200602.mbox/%3c43EB7B7F.1000403@apache.org%3e

In NetUI, if we had a webapp-wide Context object, we configure / stash
logging infrastructure (along with the caches that need to exist in
order to support running NetUI in a shared classloader, but that's a
separate discussion).

  ;)

Eddie




On 3/8/06, Daryl Olander <do...@gmail.com> wrote:
> FYI...From the Struts List...I know that NetUI uses this (anti-)pattern all
> over it.  I'm pretty sure we are not deploying in shared classloaders, but
> I'm not sure of all of the scenario's we expect to be deployed in.  I don't
> believe this pattern is used in Controls at all.
>
> ---------- Forwarded message ----------
> From: Simon Kitching <sk...@apache.org>
> Date: Mar 7, 2006 7:50 PM
> Subject: commons-logging and static log members
> To: dev@struts.apache.org
>
> Hi All,
>
> Recently there was a discussion on the MyFaces list regarding the use of
> the following pattern with commons logging classes:
>   private static Log log = LogFactory.getLog(Foo.class)
>
> It was pointed out that the use of static here is a really bad idea for
> any code that may be deployed via a shared classloader in a container.
> Craig McClanahan indicated that this (anti-)pattern was in use in struts
> code and that the issue should be pointed out here.
>
> I haven't personally checked whether this usage *is* present in the
> current struts codebase. Neither do I know whether struts jarfiles are
> expected to be deployed in shared classpaths (it's definitely true for
> MyFaces).
>
> More information on this issue can be found here:
> http://wiki.apache.org/jakarta-commons/Logging/StaticLog
>
> Regards,
>
> Simon (commons-logging committer)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

Fwd: commons-logging and static log members

Posted by Daryl Olander <do...@gmail.com>.
FYI...From the Struts List...I know that NetUI uses this (anti-)pattern all
over it.  I'm pretty sure we are not deploying in shared classloaders, but
I'm not sure of all of the scenario's we expect to be deployed in.  I don't
believe this pattern is used in Controls at all.

---------- Forwarded message ----------
From: Simon Kitching <sk...@apache.org>
Date: Mar 7, 2006 7:50 PM
Subject: commons-logging and static log members
To: dev@struts.apache.org

Hi All,

Recently there was a discussion on the MyFaces list regarding the use of
the following pattern with commons logging classes:
  private static Log log = LogFactory.getLog(Foo.class)

It was pointed out that the use of static here is a really bad idea for
any code that may be deployed via a shared classloader in a container.
Craig McClanahan indicated that this (anti-)pattern was in use in struts
code and that the issue should be pointed out here.

I haven't personally checked whether this usage *is* present in the
current struts codebase. Neither do I know whether struts jarfiles are
expected to be deployed in shared classpaths (it's definitely true for
MyFaces).

More information on this issue can be found here:
http://wiki.apache.org/jakarta-commons/Logging/StaticLog

Regards,

Simon (commons-logging committer)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org