Mercurial Hosting > luan
view src/goodjava/logger/ThreadLocalAppender.java @ 1709:6378d261136e
rm postgres backups
author | Vadim Filimonov <fffilimonov@yandex.ru> |
---|---|
date | Tue, 05 Jul 2022 13:37:05 +0300 |
parents | 74c534de211f |
children |
line wrap: on
line source
package goodjava.logger; public final class ThreadLocalAppender implements Appender { public volatile Appender defaultAppender; public final ThreadLocal<Appender> threadLocal = new InheritableThreadLocal<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(); } }