本文整理了Java中org.apache.logging.log4j.core.Logger.error()
方法的一些代码示例,展示了Logger.error()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.error()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:error
暂无
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void error(@Nullable String marker, String msg, @Nullable Throwable e) {
impl.error(getMarkerOrNull(marker), msg, e);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(ScriptAppenderSelectorTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(RoutesScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(DefaultRouteScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
public void testNoNulCharacters(final String message, final String expected) throws IOException {
@SuppressWarnings("resource")
final LoggerContext loggerContext = loggerContextRule.getLoggerContext();
final Logger logger = loggerContext.getLogger("com.example");
logger.error("log:", message);
loggerContext.stop();
final File file = new File(FILE_PATH);
final byte[] contents = Files.toByteArray(file);
int count0s = 0;
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < contents.length; i++) {
final byte b = contents[i];
if (b == 0) {
sb.append(i);
sb.append(", ");
count0s++;
}
}
Assert.assertEquals("File contains " + count0s + " 0x00 byte at indices " + sb, 0, count0s);
final List<String> readLines = Files.readLines(file, Charset.defaultCharset());
final String actual = readLines.get(0);
// Assert.assertTrue(actual, actual.contains(message));
Assert.assertEquals(actual, expected, actual);
Assert.assertEquals(1, readLines.size());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testAdditivity() throws Exception {
final Logger localLogger = context.getLogger("org.apache.test");
localLogger.error("Test parent additivity");
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 1);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLogJsonArgument() throws InterruptedException {
final ListAppender appender = (ListAppender) init.getAppender("List");
appender.countDownLatch = new CountDownLatch(4);
appender.clear();
final Logger logger = (Logger) LogManager.getRootLogger();
final String json = "{\"id\":10,\"name\":\"Alice\"}";
logger.error("log:{}", json);
// wait until background thread finished processing
final int msgCount = 1;
if (appender.getMessages().size() < msgCount) {
appender.countDownLatch.await(5, TimeUnit.SECONDS);
}
assertEquals("Background thread did not finish processing: msg count", msgCount, appender.getMessages().size());
// don't stop appender until background thread is done
appender.stop();
final List<String> list = appender.getMessages();
final String eventStr = list.get(0).toString();
Assert.assertTrue(eventStr, eventStr.contains(json));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
ThreadContext.remove("key2");
root.error("finished mdc pattern test", new NullPointerException("test"));
代码示例来源:origin: org.apache.logging.log4j/log4j-core
ThreadContext.remove("key2");
root.error("finished mdc pattern test", new NullPointerException("test"));
root.error("Throwing an exception", child);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
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
private void testSmtpAppender(Logger logger) {
ThreadContext.put("MDC1", "mdc1");
logger.error("the message");
ctx.getLoggerContext().stop();
smtpServer.stop();
assertEquals(1, smtpServer.getReceivedEmailSize());
final Iterator<SmtpMessage> messages = smtpServer.getReceivedEmail();
final SmtpMessage email = messages.next();
assertEquals("to@example.com", email.getHeaderValue("To"));
assertEquals("from@example.com", email.getHeaderValue("From"));
assertEquals("[mdc1]", email.getHeaderValue("Subject"));
String body = email.getBody();
if (!body.contains("Body:[mdc1]")) {
fail(body);
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
ThreadContext.remove("key2");
this.rootLogger.error("finished mdc pattern test", new NullPointerException("test"));
this.rootLogger.error(marker, "marker test");
代码示例来源:origin: mulesoft/mule
@Override
public void error(Marker marker, Object message, Throwable t) {
getLogger().error(marker, message, t);
}
代码示例来源:origin: mulesoft/mule
@Override
public void error(Marker marker, String message) {
getLogger().error(marker, message);
}
代码示例来源:origin: mulesoft/mule
@Override
public void error(String message) {
getLogger().error(message);
}
代码示例来源:origin: mulesoft/mule
@Override
public void error(String message, Throwable t) {
getLogger().error(message, t);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
root.error(LINE3, exception);
代码示例来源:origin: org.apache.logging.log4j/log4j-core
ThreadContext.remove("key2");
this.rootLogger.error("finished mdc pattern test", new NullPointerException("test"));
代码示例来源:origin: org.apache.logging.log4j/log4j-core
ThreadContext.remove("key2");
this.rootLogger.error("finished mdc pattern test", new NullPointerException("test"));
代码示例来源:origin: org.apache.logging.log4j/log4j-core
logger.debug("This is a test message");
final Throwable child = new LoggingException(expectedExMsg);
logger.error("Throwing an exception", child);
logger.debug("This is another test message");
} finally {
内容来源于网络,如有侵权,请联系作者删除!