Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class MDC
- Object
- MDC
A per-thread context map appended to every line logged on that thread, as slf4j’s MDC is: put a request id once and every line of that request carries it.
MDC.put("request", requestId);
try {
handle(request);
} finally {
MDC.remove("request");
}
The map belongs to the thread, a virtual thread included, so a value put by one request is never seen by another. Remove what you put: a pooled thread otherwise carries it into the next request it serves.
Methods
public static void put(String key, String value) | Sets key for every line this thread logs from now on; a null value removes it. |
public static String get(String key) | The value this thread set for key, or null. |
public static void remove(String key) | Removes key from this thread’s context. |
public static void clear() | Empties this thread’s context. |
Inherited methods
Method details
put
public static void put(String key, String value)Sets
key for every line this thread logs from now on; a null value
removes it.get
public static String get(String key)The value this thread set for
key, or null.remove
public static void remove(String key)Removes
key from this thread’s context.clear
public static void clear()Empties this thread’s context.