當前位置: 首頁>>代碼示例>>Java>>正文


Java EventLogger類代碼示例

本文整理匯總了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");
    }
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:26,代碼來源:EventLoggerTest.java

示例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);
}
 
開發者ID:OuZhencong,項目名稱:log4j2,代碼行數:17,代碼來源:LoggerTest.java

示例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);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:17,代碼來源:LoggerTest.java


注:本文中的org.slf4j.ext.EventLogger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。