Mercurial Hosting > luan
view src/goodjava/logger/ThreadLocalAppender.java @ 1450:28b1ddacfad3
logger work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 01 Mar 2020 13:47:02 -0700 |
parents | |
children | 85d7c1777357 |
line wrap: on
line source
package goodjava.logger; public class ThreadLocalAppender implements Appender { private final 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(); } }