Mercurial Hosting > luan
view src/goodjava/logger/ThreadLocalAppender.java @ 1461:e5d48b85351c
start lucene.logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 28 Mar 2020 21:30:42 -0600 |
parents | 219f2b937f2b |
children | 74c534de211f |
line wrap: on
line source
package goodjava.logger; public final class ThreadLocalAppender implements Appender { public volatile Appender defaultAppender; public final ThreadLocal<Appender> threadLocal = new ThreadLocal<Appender>(); public ThreadLocalAppender(Appender defaultAppender) { this.defaultAppender = defaultAppender; } public void append(LoggingEvent event) { Appender appender = threadLocal.get(); if( appender == null ) appender = defaultAppender; appender.append(event); } public void close() { defaultAppender.close(); } }