org.apache.logging.log4j.ThreadContext.remove()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.apache.logging.log4j.ThreadContext.remove()方法的一些代码示例,展示了ThreadContext.remove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.remove()方法的具体详情如下:
包路径:org.apache.logging.log4j.ThreadContext
类名称:ThreadContext
方法名:remove

ThreadContext.remove介绍

[英]Removes the context value identified by the key parameter.
[中]删除key参数标识的上下文值。

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
public void removeMdc(String key) {
  ThreadContext.remove(key);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl

@Override
public void remove(final String key) {
  ThreadContext.remove(key);
}

代码示例来源:origin: openzipkin/brave

@Override protected void remove(String key) {
 ThreadContext.remove(key);
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

private void closeMap() {
  for (final Iterator<Map.Entry<String, String>> it = originalValues.entrySet().iterator(); it.hasNext(); ) {
    final Map.Entry<String, String> entry = it.next();
    final String key = entry.getKey();
    final String originalValue = entry.getValue();
    if (null == originalValue) {
      ThreadContext.remove(key);
    } else {
      ThreadContext.put(key, originalValue);
    }
    it.remove();
  }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

@After
public void after() {
  ThreadContext.remove("foo");
  ThreadContext.remove("baz");
  System.clearProperty("log4j2.threadContextMap");
  System.clearProperty("log4j2.isThreadContextMapInheritable");
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

private void prepareThreadContext(boolean isThreadContextMapInheritable) {
  System.setProperty("log4j2.isThreadContextMapInheritable", Boolean.toString(isThreadContextMapInheritable));
  PropertiesUtil.getProperties().reload();
  ThreadContextTest.reinitThreadContext();
  ThreadContext.remove("baz");
  ThreadContext.put("foo", "bar");
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("key1");
ThreadContext.remove("key2");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.put("count", String.valueOf(i));
} else {
  ThreadContext.remove("count");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("key1");
ThreadContext.remove("key2");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("loginId");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("loginId");

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testContainsKey() {
  ThreadContext.clearMap();
  assertFalse(ThreadContext.containsKey("testKey"));
  ThreadContext.put("testKey", "testValue");
  assertTrue(ThreadContext.containsKey("testKey"));
  ThreadContext.remove("testKey");
  assertFalse(ThreadContext.containsKey("testKey"));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testContainsKey() {
  ThreadContext.clearMap();
  assertFalse(ThreadContext.containsKey("testKey"));
  ThreadContext.put("testKey", "testValue");
  assertTrue(ThreadContext.containsKey("testKey"));
  ThreadContext.remove("testKey");
  assertFalse(ThreadContext.containsKey("testKey"));
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("key1");
ThreadContext.remove("key2");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("key1");
ThreadContext.remove("key2");

代码示例来源:origin: org.apache.logging.log4j/log4j-core

ThreadContext.remove("key1");
ThreadContext.remove("key2");

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testRemove() {
  ThreadContext.clearMap();
  assertNull(ThreadContext.get("testKey"));
  ThreadContext.put("testKey", "testValue");
  assertEquals("testValue", ThreadContext.get("testKey"));
  ThreadContext.remove("testKey");
  assertNull(ThreadContext.get("testKey"));
  assertTrue(ThreadContext.isEmpty());
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

@Test
public void testRemove() {
  ThreadContext.clearMap();
  assertNull(ThreadContext.get("testKey"));
  ThreadContext.put("testKey", "testValue");
  assertEquals("testValue", ThreadContext.get("testKey"));
  ThreadContext.remove("testKey");
  assertNull(ThreadContext.get("testKey"));
  assertTrue(ThreadContext.isEmpty());
}

代码示例来源:origin: org.apache.logging.log4j/log4j-core

logger.debug("This is another test message");
} finally {
  ThreadContext.remove(tcKey);
  ThreadContext.pop();

代码示例来源:origin: org.apache.logging.log4j/log4j-core

assertTrue(filter.isStarted());
assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
ThreadContext.remove("userid");
assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
ThreadContext.put("userid", "JohnDoe");
ThreadContext.put("organization", "ASF");
assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
ThreadContext.remove("organization");
assertSame(Filter.Result.DENY, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
final KeyValuePair[] single = new KeyValuePair[] {new KeyValuePair("userid", "testuser")};

相关文章