If I understand it correctly, FileLock.lock() (called in ch.qos.logback.core.FileAppender#safeWrite:254) throws the OverlappingFileLockException when a thread already has the lock: "throws OverlappingFileLockException – If a lock that overlaps the requested region is already held by this Java virtual machine, or if another thread is already blocked in this method and is attempting to lock an overlapping region". FileLock.lock() always tries to aquire the same region (0 - Long.MAX_VALUE). Therefore other threads calling lock() are not blocked until the lock is released, but instantly receive the Exception. If that is true, then safeWrite doesn't seem to be thread-safe. in 1.2.12 ch.qos.logback.core.OutputStreamAppender#writeBytes:197 uses a ReentrantLock that blocks access until i becomes available: "If the lock is held by another thread then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired" |