[logback-user] Something which should be made clearer in the logback doc: Should a layout be threadsafe?

Ralph Goers rgoers at apache.org
Tue Oct 25 03:48:24 CEST 2011


Actually, Logback was originally designed with the assumption that Layouts were not thread-safe. I'm not sure if it is still the case, but at one PatternLayout was not. If you look at AppenderBase you will see that.  UnsynchronizedAppenderBase was created for Appenders that are completely thread-safe, including the Layouts they use.

FWIW, I agree that Layouts should always be thread-safe.

Ralph

On Oct 24, 2011, at 5:29 PM, jakartaman wrote:

> Hi,
> 
> Quick remark:
> 
> It is not clear from the logback docs whether a new layout should be threadsafe. I strongly suspect that it should be (why would logback do the possibly unnecessary locking for you?), but - should that not be explicitly said?
> 
> E.g. coders may fall into the usual trap of having an instance-bound or even static SimpleDateFormat member and not making the access to it synchronized etc (aehm).
> 
> 
> Best regards,
> 
> --- David
> 
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user



More information about the Logback-user mailing list