| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (1.8.0_144) on Sat Apr 25 12:08:07 MST 2020 --> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>ThreadContext (Apache Log4j API 2.13.2 API)</title> |
| <meta name="date" content="2020-04-25"> |
| <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="ThreadContext (Apache Log4j API 2.13.2 API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9,"i21":9,"i22":9,"i23":9}; |
| var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/ThreadContext.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/logging/log4j/MarkerManager.Log4jMarker.html" title="class in org.apache.logging.log4j"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/logging/log4j/ThreadContext.html" target="_top">Frames</a></li> |
| <li><a href="ThreadContext.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li><a href="#nested.class.summary">Nested</a> | </li> |
| <li><a href="#field.summary">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field.detail">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">org.apache.logging.log4j</div> |
| <h2 title="Class ThreadContext" class="title">Class ThreadContext</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.logging.log4j.ThreadContext</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <hr> |
| <br> |
| <pre>public final class <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.49">ThreadContext</a> |
| extends <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></pre> |
| <div class="block">The ThreadContext allows applications to store information either in a Map or a Stack. |
| <p> |
| <b><em>The MDC is managed on a per thread basis</em></b>. To enable automatic inheritance of <i>copies</i> of the MDC |
| to newly created threads, enable the Log4j system property. |
| </p></div> |
| <dl> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="https://logging.apache.org/log4j/2.x/manual/thread-context.html">Thread Context Manual</a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ======== NESTED CLASS SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="nested.class.summary"> |
| <!-- --> |
| </a> |
| <h3>Nested Class Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Nested Class Summary table, listing nested classes, and an explanation"> |
| <caption><span>Nested Classes</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Class and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static interface </code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j">ThreadContext.ContextStack</a></span></code> |
| <div class="block">The ThreadContext Stack interface.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- =========== FIELD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="field.summary"> |
| <!-- --> |
| </a> |
| <h3>Field Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation"> |
| <caption><span>Fields</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Field and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#EMPTY_MAP">EMPTY_MAP</a></span></code> |
| <div class="block">Empty, immutable Map.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../org/apache/logging/log4j/spi/ThreadContextStack.html" title="interface in org.apache.logging.log4j.spi">ThreadContextStack</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#EMPTY_STACK">EMPTY_STACK</a></span></code> |
| <div class="block">Empty, immutable ContextStack.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#clearAll--">clearAll</a></span>()</code> |
| <div class="block">Clears the context map and stack.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#clearMap--">clearMap</a></span>()</code> |
| <div class="block">Clears the context map.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#clearStack--">clearStack</a></span>()</code> |
| <div class="block">Clears the stack for this thread.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j">ThreadContext.ContextStack</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#cloneStack--">cloneStack</a></span>()</code> |
| <div class="block">Returns a copy of this thread's stack.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code>static boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#containsKey-java.lang.String-">containsKey</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</code> |
| <div class="block">Determines if the key is in the context.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#get-java.lang.String-">get</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</code> |
| <div class="block">Gets the context value identified by the <code>key</code> parameter.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getContext--">getContext</a></span>()</code> |
| <div class="block">Returns a mutable copy of current thread's context Map.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code>static int</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getDepth--">getDepth</a></span>()</code> |
| <div class="block">Gets the current nesting depth of this thread's stack.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getImmutableContext--">getImmutableContext</a></span>()</code> |
| <div class="block">Returns an immutable view of the current thread's context Map.</div> |
| </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code>static <a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j">ThreadContext.ContextStack</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getImmutableStack--">getImmutableStack</a></span>()</code> |
| <div class="block">Gets an immutable copy of this current thread's context stack.</div> |
| </td> |
| </tr> |
| <tr id="i10" class="altColor"> |
| <td class="colFirst"><code>static <a href="../../../../org/apache/logging/log4j/spi/ReadOnlyThreadContextMap.html" title="interface in org.apache.logging.log4j.spi">ReadOnlyThreadContextMap</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getThreadContextMap--">getThreadContextMap</a></span>()</code> |
| <div class="block">Returns a read-only view of the internal data structure used to store thread context key-value pairs, |
| or <code>null</code> if the internal data structure does not implement the |
| <code>ReadOnlyThreadContextMap</code> interface.</div> |
| </td> |
| </tr> |
| <tr id="i11" class="rowColor"> |
| <td class="colFirst"><code>static boolean</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#isEmpty--">isEmpty</a></span>()</code> |
| <div class="block">Returns true if the Map is empty.</div> |
| </td> |
| </tr> |
| <tr id="i12" class="altColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#peek--">peek</a></span>()</code> |
| <div class="block">Looks at the last diagnostic context at the top of this NDC without removing it.</div> |
| </td> |
| </tr> |
| <tr id="i13" class="rowColor"> |
| <td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#pop--">pop</a></span>()</code> |
| <div class="block">Returns the value of the last item placed on the stack.</div> |
| </td> |
| </tr> |
| <tr id="i14" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#push-java.lang.String-">push</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> message)</code> |
| <div class="block">Pushes new diagnostic context information for the current thread.</div> |
| </td> |
| </tr> |
| <tr id="i15" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#push-java.lang.String-java.lang.Object...-">push</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> message, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>... args)</code> |
| <div class="block">Pushes new diagnostic context information for the current thread.</div> |
| </td> |
| </tr> |
| <tr id="i16" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#put-java.lang.String-java.lang.String-">put</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value)</code> |
| <div class="block">Puts a context value (the <code>value</code> parameter) as identified with the <code>key</code> parameter into |
| the current thread's context map.</div> |
| </td> |
| </tr> |
| <tr id="i17" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#putAll-java.util.Map-">putAll</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> m)</code> |
| <div class="block">Puts all given context map entries into the current thread's |
| context map.</div> |
| </td> |
| </tr> |
| <tr id="i18" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#putIfNull-java.lang.String-java.lang.String-">putIfNull</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value)</code> |
| <div class="block">Puts a context value (the <code>value</code> parameter) as identified with the <code>key</code> parameter into |
| the current thread's context map if the key does not exist.</div> |
| </td> |
| </tr> |
| <tr id="i19" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#remove-java.lang.String-">remove</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</code> |
| <div class="block">Removes the context value identified by the <code>key</code> parameter.</div> |
| </td> |
| </tr> |
| <tr id="i20" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#removeAll-java.lang.Iterable-">removeAll</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> keys)</code> |
| <div class="block">Removes the context values identified by the <code>keys</code> parameter.</div> |
| </td> |
| </tr> |
| <tr id="i21" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#removeStack--">removeStack</a></span>()</code> |
| <div class="block">Removes the diagnostic context for this thread.</div> |
| </td> |
| </tr> |
| <tr id="i22" class="altColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#setStack-java.util.Collection-">setStack</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> stack)</code> |
| <div class="block">Sets this thread's stack.</div> |
| </td> |
| </tr> |
| <tr id="i23" class="rowColor"> |
| <td class="colFirst"><code>static void</code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/logging/log4j/ThreadContext.html#trim-int-">trim</a></span>(int depth)</code> |
| <div class="block">Trims elements from this diagnostic context.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ FIELD DETAIL =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="field.detail"> |
| <!-- --> |
| </a> |
| <h3>Field Detail</h3> |
| <a name="EMPTY_MAP"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>EMPTY_MAP</h4> |
| <pre>public static final <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.182">EMPTY_MAP</a></pre> |
| <div class="block">Empty, immutable Map.</div> |
| </li> |
| </ul> |
| <a name="EMPTY_STACK"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>EMPTY_STACK</h4> |
| <pre>public static final <a href="../../../../org/apache/logging/log4j/spi/ThreadContextStack.html" title="interface in org.apache.logging.log4j.spi">ThreadContextStack</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.189">EMPTY_STACK</a></pre> |
| <div class="block">Empty, immutable ContextStack.</div> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="put-java.lang.String-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>put</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.243">put</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value)</pre> |
| <div class="block">Puts a context value (the <code>value</code> parameter) as identified with the <code>key</code> parameter into |
| the current thread's context map. |
| |
| <p> |
| If the current thread does not have a context map it is created as a side effect. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>key</code> - The key name.</dd> |
| <dd><code>value</code> - The key value.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="putIfNull-java.lang.String-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>putIfNull</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.259">putIfNull</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> value)</pre> |
| <div class="block">Puts a context value (the <code>value</code> parameter) as identified with the <code>key</code> parameter into |
| the current thread's context map if the key does not exist. |
| |
| <p> |
| If the current thread does not have a context map it is created as a side effect. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>key</code> - The key name.</dd> |
| <dd><code>value</code> - The key value.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>2.13.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="putAll-java.util.Map-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>putAll</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.274">putAll</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> m)</pre> |
| <div class="block">Puts all given context map entries into the current thread's |
| context map. |
| |
| <p>If the current thread does not have a context map it is |
| created as a side effect.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>m</code> - The map.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>2.7</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="get-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>get</h4> |
| <pre>public static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.296">get</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</pre> |
| <div class="block">Gets the context value identified by the <code>key</code> parameter. |
| |
| <p> |
| This method has no side effects. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>key</code> - The key to locate.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>The value associated with the key or null.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="remove-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>remove</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.305">remove</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</pre> |
| <div class="block">Removes the context value identified by the <code>key</code> parameter.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>key</code> - The key to remove.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="removeAll-java.lang.Iterable-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>removeAll</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.316">removeAll</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> keys)</pre> |
| <div class="block">Removes the context values identified by the <code>keys</code> parameter.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>keys</code> - The keys to remove.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>2.8</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="clearMap--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>clearMap</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.331">clearMap</a>()</pre> |
| <div class="block">Clears the context map.</div> |
| </li> |
| </ul> |
| <a name="clearAll--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>clearAll</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.338">clearAll</a>()</pre> |
| <div class="block">Clears the context map and stack.</div> |
| </li> |
| </ul> |
| <a name="containsKey-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>containsKey</h4> |
| <pre>public static boolean <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.349">containsKey</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> key)</pre> |
| <div class="block">Determines if the key is in the context.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>key</code> - The key to locate.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>True if the key is in the context, false otherwise.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getContext--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getContext</h4> |
| <pre>public static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.358">getContext</a>()</pre> |
| <div class="block">Returns a mutable copy of current thread's context Map.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>a mutable copy of the context.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getImmutableContext--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getImmutableContext</h4> |
| <pre>public static <a href="https://docs.oracle.com/javase/8/docs/api/java/util/Map.html?is-external=true" title="class or interface in java.util">Map</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>,<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.367">getImmutableContext</a>()</pre> |
| <div class="block">Returns an immutable view of the current thread's context Map.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>An immutable view of the ThreadContext Map.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getThreadContextMap--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getThreadContextMap</h4> |
| <pre>public static <a href="../../../../org/apache/logging/log4j/spi/ReadOnlyThreadContextMap.html" title="interface in org.apache.logging.log4j.spi">ReadOnlyThreadContextMap</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.388">getThreadContextMap</a>()</pre> |
| <div class="block">Returns a read-only view of the internal data structure used to store thread context key-value pairs, |
| or <code>null</code> if the internal data structure does not implement the |
| <code>ReadOnlyThreadContextMap</code> interface. |
| <p> |
| The <a href="../../../../org/apache/logging/log4j/spi/DefaultThreadContextMap.html" title="class in org.apache.logging.log4j.spi"><code>DefaultThreadContextMap</code></a> implementation does not implement <code>ReadOnlyThreadContextMap</code>, so by |
| default this method returns <code>null</code>. |
| </p></div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the internal data structure used to store thread context key-value pairs or <code>null</code></dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>2.8</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/logging/log4j/spi/ThreadContextMapFactory.html" title="class in org.apache.logging.log4j.spi"><code>ThreadContextMapFactory</code></a>, |
| <a href="../../../../org/apache/logging/log4j/spi/DefaultThreadContextMap.html" title="class in org.apache.logging.log4j.spi"><code>DefaultThreadContextMap</code></a>, |
| <code>CopyOnWriteSortedArrayThreadContextMap</code>, |
| <code>GarbageFreeSortedArrayThreadContextMap</code></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="isEmpty--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>isEmpty</h4> |
| <pre>public static boolean <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.397">isEmpty</a>()</pre> |
| <div class="block">Returns true if the Map is empty.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>true if the Map is empty, false otherwise.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="clearStack--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>clearStack</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.404">clearStack</a>()</pre> |
| <div class="block">Clears the stack for this thread.</div> |
| </li> |
| </ul> |
| <a name="cloneStack--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>cloneStack</h4> |
| <pre>public static <a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j">ThreadContext.ContextStack</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.413">cloneStack</a>()</pre> |
| <div class="block">Returns a copy of this thread's stack.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>A copy of this thread's stack.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getImmutableStack--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getImmutableStack</h4> |
| <pre>public static <a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j">ThreadContext.ContextStack</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.422">getImmutableStack</a>()</pre> |
| <div class="block">Gets an immutable copy of this current thread's context stack.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>an immutable copy of the ThreadContext stack.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="setStack-java.util.Collection-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>setStack</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.432">setStack</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html?is-external=true" title="class or interface in java.util">Collection</a><<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> stack)</pre> |
| <div class="block">Sets this thread's stack.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>stack</code> - The stack to use.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getDepth--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getDepth</h4> |
| <pre>public static int <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.447">getDepth</a>()</pre> |
| <div class="block">Gets the current nesting depth of this thread's stack.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the number of items in the stack.</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/logging/log4j/ThreadContext.html#trim-int-"><code>trim(int)</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="pop--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>pop</h4> |
| <pre>public static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.461">pop</a>()</pre> |
| <div class="block">Returns the value of the last item placed on the stack. |
| |
| <p> |
| The returned value is the value that was pushed last. If no context is available, then the empty string "" is |
| returned. |
| </p></div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>String The innermost diagnostic context.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="peek--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>peek</h4> |
| <pre>public static <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.475">peek</a>()</pre> |
| <div class="block">Looks at the last diagnostic context at the top of this NDC without removing it. |
| |
| <p> |
| The returned value is the value that was pushed last. If no context is available, then the empty string "" is |
| returned. |
| </p></div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>String The innermost diagnostic context.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="push-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>push</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.488">push</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> message)</pre> |
| <div class="block">Pushes new diagnostic context information for the current thread. |
| |
| <p> |
| The contents of the <code>message</code> parameter is determined solely by the client. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>message</code> - The new diagnostic context information.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="push-java.lang.String-java.lang.Object...-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>push</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.504">push</a>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> message, |
| <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>... args)</pre> |
| <div class="block">Pushes new diagnostic context information for the current thread. |
| |
| <p> |
| The contents of the <code>message</code> and args parameters are determined solely by the client. The message |
| will be treated as a format String and tokens will be replaced with the String value of the arguments in |
| accordance with ParameterizedMessage. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>message</code> - The new diagnostic context information.</dd> |
| <dd><code>args</code> - Parameters for the message.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="removeStack--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>removeStack</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.524">removeStack</a>()</pre> |
| <div class="block">Removes the diagnostic context for this thread. |
| |
| <p> |
| Each thread that created a diagnostic context by calling <a href="../../../../org/apache/logging/log4j/ThreadContext.html#push-java.lang.String-"><code>push(java.lang.String)</code></a> should call this method before exiting. |
| Otherwise, the memory used by the <b>thread</b> cannot be reclaimed by the VM. |
| </p> |
| |
| <p> |
| As this is such an important problem in heavy duty systems and because it is difficult to always guarantee that |
| the remove method is called before exiting a thread, this method has been augmented to lazily remove references |
| to dead threads. In practice, this means that you can be a little sloppy and occasionally forget to call |
| <a href="../../../../org/apache/logging/log4j/ThreadContext.html#remove-java.lang.String-"><code>remove(java.lang.String)</code></a> before exiting a thread. However, you must call <code>remove</code> sometime. If you never call |
| it, then your application is sure to run out of memory. |
| </p></div> |
| </li> |
| </ul> |
| <a name="trim-int-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>trim</h4> |
| <pre>public static void <a href="../../../../src-html/org/apache/logging/log4j/ThreadContext.html#line.560">trim</a>(int depth)</pre> |
| <div class="block">Trims elements from this diagnostic context. If the current depth is smaller or equal to <code>maxDepth</code>, |
| then no action is taken. If the current depth is larger than newDepth then all elements at maxDepth or higher are |
| discarded. |
| |
| <p> |
| This method is a convenient alternative to multiple <a href="../../../../org/apache/logging/log4j/ThreadContext.html#pop--"><code>pop()</code></a> calls. Moreover, it is often the case that at |
| the end of complex call sequences, the depth of the ThreadContext is unpredictable. The <code>trim</code> method |
| circumvents this problem. |
| </p> |
| |
| <p> |
| For example, the combination |
| </p> |
| |
| <pre> |
| void foo() { |
| final int depth = ThreadContext.getDepth(); |
| |
| // ... complex sequence of calls |
| |
| ThreadContext.trim(depth); |
| } |
| </pre> |
| |
| <p> |
| ensures that between the entry and exit of <code>foo</code> the depth of the diagnostic stack is conserved. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>depth</code> - The number of elements to keep.</dd> |
| <dt><span class="seeLabel">See Also:</span></dt> |
| <dd><a href="../../../../org/apache/logging/log4j/ThreadContext.html#getDepth--"><code>getDepth()</code></a></dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/ThreadContext.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../../org/apache/logging/log4j/MarkerManager.Log4jMarker.html" title="class in org.apache.logging.log4j"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../../org/apache/logging/log4j/ThreadContext.ContextStack.html" title="interface in org.apache.logging.log4j"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../index.html?org/apache/logging/log4j/ThreadContext.html" target="_top">Frames</a></li> |
| <li><a href="ThreadContext.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li><a href="#nested.class.summary">Nested</a> | </li> |
| <li><a href="#field.summary">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li><a href="#field.detail">Field</a> | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small><p align="center">Copyright © 1999-2020 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.<br /> Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.</p></small></p> |
| </body> |
| </html> |