All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tracee.backend.log4j.Log4jTraceeBackend Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
package io.tracee.backend.log4j;

import io.tracee.MDCLikeTraceeBackend;
import io.tracee.TraceeLogger;
import io.tracee.TraceeLoggerFactory;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;

import java.util.Set;

final class Log4jTraceeBackend extends MDCLikeTraceeBackend {

	Log4jTraceeBackend(ThreadLocal> traceeKeys) {
		super(traceeKeys, new TraceeLoggerFactory() {
			@Override
			public TraceeLogger getLogger(Class clazz) {
				return new Log4jTraceeLogger(Logger.getLogger(clazz));
			}
		});
	}

	@Override
	protected String getFromMdc(String key) {
		final Object mdcValue = MDC.get(key);
		if (mdcValue == null) {
			return null;
		}
		return String.valueOf(mdcValue);
	}

	@Override
	protected void putToMdc(String key, String value) {
		MDC.put(key, value);
	}

	@Override
	protected void removeFromMdc(String key) {
		MDC.remove(key);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy