commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerome Jacobsen" <>
Subject RE: [Logging] Thread safety guaruntee of Log classes?
Date Thu, 12 Dec 2002 13:40:35 GMT
Yes, I agree.  I certainly get that point.  A Log implementation that didn't
allow seperate Log instances in seperate threads would truly be pathetic.
However since the Commons Logging API makes no thread-safety restrictions
such an implementation would still be valid.  I was wrong to imply that one
Log instance per Component instance was guaranteed to be thread-safe.

Obviously I've failed to communicate the point I was trying to make.  What I
was trying to say is that either Commons Logging should declare that
implementations should be thread-safe or Struts should warn that its use of
Commons Logging requires a thread-safe Commons Logging implemenation.  Since
I'm hearing that Commons Logging was not intended to require thread-safe
implementations then Struts should provide the warning.  Struts has a
dependency on a thread-safe Commons Logging implementation.

It would also be responsible to document thread-safety implications in the
Commons Logging API.

But alas I've got the answer to my original question.  Commons Logging
implies no thread-safety.  It is up to the implementation.  User be aware.
Thanks Craig and others for hashing this out with me.  If nothing else this
thread exists as some documentation of thread-safety issues and Commons

> -----Original Message-----
> From: Craig R. McClanahan []
> Sent: Wednesday, December 11, 2002 6:02 PM
> To: Jakarta Commons Users List;
> Subject: RE: [Logging] Thread safety guaruntee of Log classes?
> 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.
> Craig
> --
> To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message