
net.jmatrix.context.LogContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmutils Show documentation
Show all versions of jmutils Show documentation
PerfTrack and Async utilities.
package net.jmatrix.context;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.jmatrix.utils.ClassLogFactory;
import org.slf4j.Logger;
import org.slf4j.MDC;
/**
* The LogContext stores threadlocal contextual information, very similar to
* the SLF4J's MDC - mapped diagnostic context.
*
* In fact, many variables here will be pushed to the MDC.
*
* However, we are trying to avoid direct, pervasive compile-time dependence
* on MDC. This abstraction facilitates that move.
*
* Looking at this class... I'm keeping MDC - a HashMap in lock-step with
* a local HashMap as long as the values are Strings. This is a restriction
* on SLF4J's MDC. Why not just use MDC as the datastore? A fair question.
* I guess for some variables may not be relevant to logging... I don't know.
* Could probably change it in the future. Its fully encapsulated here - so
* a change would not matter. Not much harm in storing it twice at the moment.
*
* */
public class LogContext {
static Logger log=ClassLogFactory.getLog();
public static final String TRANSPORT="TRANSPORT";
public static final String CLIENT_IP="CLIENT_IP";
public static final String SESSION_ID="SESSION_ID";
public static final String REQUEST_ID="REQUEST_ID";
public static final String LOGIN_ID="LOGIN_ID";
public static final String ACCOUNT_NUMBER="ACCOUNT_NUMBER";
private static class ThreadLocalContext extends ThreadLocal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy