mwomack 2003/03/18 22:02:59 Modified: src/java/org/apache/log4j/spi LoggingEvent.java Log: Added getMDCKeySet() method to return an unmodifiable set of the keys in the MDC. If the MDC is null, then an empty set is returned. Revision Changes Path 1.37 +22 -0 jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java Index: LoggingEvent.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/LoggingEvent.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- LoggingEvent.java 18 Mar 2003 13:33:31 -0000 1.36 +++ LoggingEvent.java 19 Mar 2003 06:02:59 -0000 1.37 @@ -59,6 +59,8 @@ import java.lang.reflect.Method; import java.util.Hashtable; +import java.util.Set; +import java.util.Collections; // Contributors: Nelson Minar <[EMAIL PROTECTED]> @@ -354,6 +356,26 @@ return MDC.get(key); } + /** + * Returns the set of of the key values in the MDC for the event. + * The returned set is unmodifiable by the caller. + * + * @return Iterator an iterator to iterate over the MDC keys. + * @since 1.3 + */ + public Set getMDCKeySet() { + if (mdcCopy != null) { + return Collections.unmodifiableSet(mdcCopy.keySet()); + } else { + Hashtable t = (Hashtable) MDC.getContext(); + if (t != null) { + return Collections.unmodifiableSet(t.keySet()); + } else { + return Collections.EMPTY_SET; + } + } + } + /** * Obtain a copy of this thread's MDC prior to serialization or asynchronous * logging.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]