本文整理匯總了Java中org.slf4j.ext.EventLogger類的典型用法代碼示例。如果您正苦於以下問題:Java EventLogger類的具體用法?Java EventLogger怎麽用?Java EventLogger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EventLogger類屬於org.slf4j.ext包,在下文中一共展示了EventLogger類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testEventLogger
import org.slf4j.ext.EventLogger; //導入依賴的package包/類
public void testEventLogger() {
EventData data[] = new EventData[2];
data[0] = new EventData();
data[0].setEventType("Login");
data[0].setEventId("1");
data[0].setEventDateTime(new Date());
data[0].put("Userid", "TestUser");
EventLogger.logEvent(data[0]);
data[1] = new EventData();
data[1].setEventType("Update");
data[1].setEventId("2");
data[1].setEventDateTime(new Date());
data[1].put("FileName", "/etc/hosts");
EventLogger.logEvent(data[1]);
assertEquals(2, listAppender.list.size());
for (int i = 0; i < 2; ++i) {
LoggingEvent event = listAppender.list.get(i);
verify(event, data[i].toXML());
LocationInfo li = event.getLocationInformation();
assertEquals(this.getClass().getName(), li.getClassName());
assertEquals(event.getMDC("hostname"), "localhost");
}
}
示例2: testEventLogger
import org.slf4j.ext.EventLogger; //導入依賴的package包/類
@Test
public void testEventLogger() {
MDC.put("loginId", "JohnDoe");
MDC.put("ipAddress", "192.168.0.120");
MDC.put("locale", Locale.US.getDisplayName());
final EventData data = new EventData();
data.setEventType("Transfer");
data.setEventId("[email protected]");
data.setMessage("Transfer Complete");
data.put("ToAccount", "123456");
data.put("FromAccount", "123457");
data.put("Amount", "200.00");
EventLogger.logEvent(data);
MDC.clear();
verify("EventLogger", "o.a.l.s.LoggerTest Transfer [[email protected] Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Constants.LINE_SEP);
}
示例3: testEventLogger
import org.slf4j.ext.EventLogger; //導入依賴的package包/類
@Test
public void testEventLogger() {
MDC.put("loginId", "JohnDoe");
MDC.put("ipAddress", "192.168.0.120");
MDC.put("locale", Locale.US.getDisplayName());
final EventData data = new EventData();
data.setEventType("Transfer");
data.setEventId("[email protected]");
data.setMessage("Transfer Complete");
data.put("ToAccount", "123456");
data.put("FromAccount", "123457");
data.put("Amount", "200.00");
EventLogger.logEvent(data);
MDC.clear();
verify("EventLogger", "o.a.l.s.LoggerTest Transfer [[email protected] Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Strings.LINE_SEPARATOR);
}