本文整理了Java中org.apache.logging.log4j.core.Logger.debug()
方法的一些代码示例,展示了Logger.debug()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.debug()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:debug
暂无
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private static void logDebugNormalApi(final Logger root) {
root.debug("with placeholders: {}{}{}", 1, 2, 3);
root.debug("without placeholders", 2, 3);
root.debug(null, 5, 6);
root.debug("invalid placeholder count {}", 7, 8, 9, 10);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
protected void sendDebugLegacyBsdMessage(final String message) {
sentMessages.add(message);
root.debug(message);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void debug(@Nullable String marker, String msg) {
if (!isDebugEnabled())
warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
impl.debug(getMarkerOrNull(marker), msg);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private static void logDebugObjectArrayMessage(final Logger root) {
root.debug(new ObjectArrayMessage(1, 2, 3));
root.debug(new ObjectArrayMessage(2, 3));
root.debug(new ObjectArrayMessage(5, 6));
root.debug(new ObjectArrayMessage(7, 8, 9, 10));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLog() {
final Logger logger = context.getLogger();
final List<LogEvent> events = listAppender.getEvents();
assertThat(events, hasSize(0));
logger.debug("Hello, {}", "World");
assertThat(events, hasSize(1));
logger.log(diagLevel, "Hello DIAG");
assertThat(events, hasSize(2));
assertEquals(events.get(1).getLevel(), diagLevel);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLog() {
final Logger logger = context.getLogger();
final List<LogEvent> events = listAppender.getEvents();
assertThat(events, hasSize(0));
logger.debug("Hello, {}", "World");
assertThat(events, hasSize(1));
logger.log(warnLevel, "Hello DIAG");
assertThat(events, hasSize(2));
assertEquals(events.get(1).getLevel(), warnLevel);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void getLogger_String_MessageFactoryMismatch() {
final Logger testLogger = testMessageFactoryMismatch(testName.getMethodName(),
StringFormatterMessageFactory.INSTANCE, ParameterizedMessageFactory.INSTANCE);
testLogger.debug("%,d", Integer.MAX_VALUE);
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 1);
assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void getLogger_String_MessageFactoryMismatchNull() {
final Logger testLogger = testMessageFactoryMismatch(testName.getMethodName(), StringFormatterMessageFactory.INSTANCE, null);
testLogger.debug("%,d", Integer.MAX_VALUE);
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 1);
assertEquals(String.format("%,d", Integer.MAX_VALUE), events.get(0).getMessage().getFormattedMessage());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.debug("starting mdc pattern test");
root.debug("empty mdc");
root.debug("filled mdc");
root.debug("This is a test");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.debug("starting mdc pattern test");
root.debug("empty mdc");
root.debug("filled mdc");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.debug("Debug message #1");
root.debug("Debug message #2");
root.debug("Debug message #3");
root.debug("Debug message #4");
root.error("Error with exception", new RuntimeException("Exception message"));
root.error("Error message #2");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.setLevel(Level.DEBUG);
root.debug("one={}, two={}, three={}", 1, 2, 3);
root.info("Hello");
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
this.rootLogger.debug("starting mdc pattern test");
this.rootLogger.debug("empty mdc");
this.rootLogger.debug("filled mdc");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
this.rootLogger.debug("starting mdc pattern test");
this.rootLogger.debug("empty mdc");
this.rootLogger.debug("filled mdc");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testUdpAppender() throws Exception {
try {
udpServer.latch.await();
} catch (final InterruptedException ex) {
ex.printStackTrace();
}
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
.withProtocol(Protocol.UDP)
.withPort(tcpServer.getLocalPort())
.withReconnectDelayMillis(-1)
.withName("test")
.withImmediateFail(false)
.withLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
// set appender on root and set level to debug
logger.addAppender(appender);
logger.setAdditive(false);
logger.setLevel(Level.DEBUG);
logger.debug("This is a udp message");
final LogEvent event = udpServer.getQueue().poll(3, TimeUnit.SECONDS);
assertNotNull("No event retrieved", event);
assertTrue("Incorrect event", event.getMessage().getFormattedMessage().equals("This is a udp message"));
assertTrue("Message not delivered via UDP", udpServer.getCount() > 0);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
this.rootLogger.debug("Here is a quote ' and then a double quote \"");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
this.rootLogger.debug("Here is a quote ' and then a double quote \"");
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testTcpAppenderDeadlock() throws Exception {
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
.withHost("localhost")
.withPort(DYN_PORT)
.withReconnectDelayMillis(100)
.withName("test")
.withImmediateFail(false)
.withLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
// set appender on root and set level to debug
logger.addAppender(appender);
logger.setAdditive(false);
logger.setLevel(Level.DEBUG);
final TcpSocketTestServer tcpSocketServer = new TcpSocketTestServer(DYN_PORT);
try {
tcpSocketServer.start();
logger.debug("This message is written because a deadlock never.");
final LogEvent event = tcpSocketServer.getQueue().poll(3, TimeUnit.SECONDS);
assertNotNull("No event retrieved", event);
} finally {
tcpSocketServer.shutdown();
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testTcpAppenderNoWait() throws Exception {
// @formatter:off
final SocketAppender appender = SocketAppender.newBuilder()
.withHost("localhost")
.withPort(ERROR_PORT)
.withReconnectDelayMillis(100)
.withName("test")
.withImmediateFail(false)
.withIgnoreExceptions(false)
.withLayout(JsonLayout.newBuilder().setProperties(true).build())
.build();
// @formatter:on
appender.start();
// set appender on root and set level to debug
logger.addAppender(appender);
logger.setAdditive(false);
logger.setLevel(Level.DEBUG);
try {
logger.debug("This message is written because a deadlock never.");
fail("No Exception was thrown");
} catch (final Exception ex) {
// TODO: move exception to @Test(expect = Exception.class)
// Failure is expected.
// ex.printStackTrace();
}
}
内容来源于网络,如有侵权,请联系作者删除!