本文整理了Java中org.apache.logging.log4j.core.Logger.removeAppender()
方法的一些代码示例,展示了Logger.removeAppender()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.removeAppender()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:removeAppender
[英]This method is not exposed through the public API and is used primarily for unit testing.
[中]此方法不通过公共API公开,主要用于单元测试。
代码示例来源:origin: alibaba/nacos
protected void removeAllAppenders(org.apache.logging.log4j.core.Logger logger) {
Map<String, Appender> appenders = logger.getAppenders();
if (appenders != null) {
for (Appender appender : appenders.values()) {
logger.removeAppender(appender);
}
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private static void removeAppenders(final Logger root) {
final Map<String, Appender> appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);
}
}
代码示例来源:origin: apache/incubator-druid
@AfterClass
public static void tearDownStatic()
{
final Logger logger = (Logger) LogManager.getLogger(
LoggingRequestLogger.class);
logger.removeAppender(appender);
appender.stop();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
protected void removeAppenders() {
final Map<String,Appender> map = root.getAppenders();
for (final Map.Entry<String, Appender> entry : map.entrySet()) {
final Appender app = entry.getValue();
root.removeAppender(app);
app.stop();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
void removeAndStopAppenders() {
final Map<String, Appender> map = logger.getAppenders();
for (final Map.Entry<String, Appender> entry : map.entrySet()) {
final Appender appender = entry.getValue();
logger.removeAppender(appender);
appender.stop();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testUDPAppender() throws Exception {
initUDPTestEnvironment("bsd");
sendAndCheckLegacyBsdMessage("This is a test message");
root.removeAppender(appender);
appender.stop();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testUDPStructuredAppender() throws Exception {
initUDPTestEnvironment("RFC5424");
sendAndCheckStructuredMessage();
root.removeAppender(appender);
appender.stop();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testSubstituteStructuredData() {
final String mdcId = "RequestContext";
final String expectedToContain = String.format("ATM %s MSG-ID - Message", PROCESSID);
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
}
final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, "Event", 3692, false, mdcId,
null, null, true, null, "ATM", "MSG-ID", "key1, key2, locale", null, null, null, false, null, null);
final ListAppender appender = new ListAppender("List", null, layout, true, false);
appender.start();
root.addAppender(appender);
root.setLevel(Level.DEBUG);
root.info("Message");
try {
final List<String> list = appender.getMessages();
assertTrue("Not enough list entries", list.size() > 0);
final String message = list.get(0);
Assert.assertTrue("Not the expected message received", message.contains(expectedToContain));
appender.clear();
} finally {
root.removeAppender(appender);
appender.stop();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testParameterizedMessage() {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
}
// set up appender
final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, "Event", 3692, true, "RequestContext",
null, null, true, null, "ATM", null, "key1, key2, locale", null, null, null, true, null, null);
final ListAppender appender = new ListAppender("List", null, layout, true, false);
appender.start();
// set appender on root and set level to debug
root.addAppender(appender);
root.setLevel(Level.DEBUG);
root.info("Hello {}", "World");
try {
final List<String> list = appender.getMessages();
assertTrue("Not enough list entries", list.size() > 0);
final String message = list.get(0);
assertTrue("Incorrect message. Expected - Hello World, Actual - " + message, message.contains("Hello World"));
} finally {
root.removeAppender(appender);
appender.stop();
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
/**
* Test case for MDC exception conversion pattern.
*/
@Test
public void testException() throws Exception {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
}
// set up layout/appender
final AbstractStringLayout layout = Rfc5424Layout.createLayout(Facility.LOCAL0, "Event", 3692, true, "RequestContext",
null, null, true, null, "ATM", null, "key1, key2, locale", null, "loginId", "%xEx", true, null, null);
final ListAppender appender = new ListAppender("List", null, layout, true, false);
appender.start();
// set appender on root and set level to debug
root.addAppender(appender);
root.setLevel(Level.DEBUG);
ThreadContext.put("loginId", "JohnDoe");
// output starting message
root.debug("starting mdc pattern test", new IllegalArgumentException("Test"));
try {
final List<String> list = appender.getMessages();
assertTrue("Not enough list entries", list.size() > 1);
final String string = list.get(1);
assertTrue("No Exception in " + string, string.contains("IllegalArgumentException"));
appender.clear();
} finally {
root.removeAppender(appender);
appender.stop();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
public void testEscape() throws Exception {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
assertTrue("No messages expected, found " + list.size(), list.isEmpty());
} finally {
root.removeAppender(appender);
appender.stop();
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private void testLayout(final CSVFormat format, final AbstractCsvLayout layout, final String header, final String footer) {
final Map<String, Appender> appenders = root.getAppenders();
for (final Appender appender : appenders.values()) {
root.removeAppender(appender);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
public void testMDCLoggerFields() throws Exception {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
root.removeAppender(appender);
appender.stop();
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.removeAppender(appender);
appender.clear();
} finally {
root.removeAppender(appender);
appender.stop();
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.removeAppender(appender);
root.removeAppender(appender);
appender.stop();
代码示例来源:origin: org.apache.logging.log4j/log4j-core
public void testLayout() throws Exception {
for (final Appender appender : root.getAppenders().values()) {
root.removeAppender(appender);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
final Map<String, Appender> appenders = this.rootLogger.getAppenders();
for (final Appender appender : appenders.values()) {
this.rootLogger.removeAppender(appender);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
final Map<String, Appender> appenders = this.rootLogger.getAppenders();
for (final Appender appender : appenders.values()) {
this.rootLogger.removeAppender(appender);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
final Map<String, Appender> appenders = this.rootLogger.getAppenders();
for (final Appender appender : appenders.values()) {
this.rootLogger.removeAppender(appender);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
final Map<String, Appender> appenders = this.rootLogger.getAppenders();
for (final Appender appender : appenders.values()) {
this.rootLogger.removeAppender(appender);
内容来源于网络,如有侵权,请联系作者删除!