LOG4J2-1348  added example usage to CloseableThreadContext class javadoc

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/065b8e06
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/065b8e06
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/065b8e06

Branch: refs/heads/LOG4J-1181
Commit: 065b8e060a71a3646795e2c21a67b49f6a9c108e
Parents: 2c40d92
Author: rpopma <rpo...@apache.org>
Authored: Tue May 31 23:28:13 2016 +0900
Committer: rpopma <rpo...@apache.org>
Committed: Tue May 31 23:28:13 2016 +0900

----------------------------------------------------------------------
 .../org/apache/logging/log4j/CloseableThreadContext.java    | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/065b8e06/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
----------------------------------------------------------------------
diff --git 
a/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java 
b/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
index ff256f2..b9a9cf0 100644
--- 
a/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
+++ 
b/log4j-api/src/main/java/org/apache/logging/log4j/CloseableThreadContext.java
@@ -22,7 +22,14 @@ import java.util.Map;
 
 /**
  * Adds entries to the {@link ThreadContext stack or map} and them removes 
them when the object is closed, e.g. as part
- * of a try-with-resources.
+ * of a try-with-resources. User code can now look like this:
+ * <pre>
+ * try (CloseableThreadContext.put(key1, value1).put(key2, value2)) {
+ *     callSomeMethodThatLogsALot();
+ *
+ * // key1 and key2 are automatically removed from the ThreadContext map when 
done
+ * }
+ * </pre>
  *
  * @since 2.6
  */

Reply via email to