commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject RE: [Logging] Thread safety guaruntee of Log classes?
Date Wed, 11 Dec 2002 23:01:57 GMT

On Wed, 11 Dec 2002, Jerome Jacobsen wrote:

> Date: Wed, 11 Dec 2002 17:49:24 -0500
> From: Jerome Jacobsen <>
> Reply-To: Jakarta Commons Users List <>,
> To: Jakarta Commons Users List <>
> Subject: RE: [Logging] Thread safety guaruntee of Log classes?
> >
> > Declaring the Log variable static or not has zero effect on whether it is
> > threadsafe or not -- it only determines whether or not the Log instance is
> > shared across all instances of the declaring class.
> >
> > Craig
> >
> Huh?  Declaring the Log instance static means that it better be thread-safe.

True, but you're missing an important point.  Exactly the same is true for
a non-static declaration.

Consider a Struts Action class.  Struts creates a single instance of your
declared Action class, and it will be quite common to have multiple
requests processing through the action at the same time (and therefore
possibly triggering log calls at the same time).

It makes absolutely no difference whether or not the log variable itself
is declared statically.  It has to be thread safe either way.


View raw message