当前位置: 首页>>代码示例>>Java>>正文


Java LoggingEvent类代码示例

本文整理汇总了Java中ch.qos.logback.classic.spi.LoggingEvent的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent类的具体用法?Java LoggingEvent怎么用?Java LoggingEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LoggingEvent类属于ch.qos.logback.classic.spi包,在下文中一共展示了LoggingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sometimesFails

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
public void sometimesFails() {
    log.warn("This is a warning.");
    log.info("This is purely informational.");

    List<LoggingEvent> logs = (List<LoggingEvent>) TestNGLogCollector.getRawLogs();

    assertThat(logs)
            .hasSize(2)
            .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.WARN))
            .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.INFO));

    invocationCount++;

    if (invocationCount > 8) {
        Assert.fail();
    }
}
 
开发者ID:haasted,项目名称:TestLogCollectors,代码行数:18,代码来源:PercentageTest.java

示例2: testDefaultValues

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void testDefaultValues() {
    final Context mockContext = mock(Context.class);

    final PutLogEventsResult mockResult = mock(PutLogEventsResult.class);
    when(mockResult.getNextSequenceToken()).thenReturn("2");

    final AWSLogs mockAwsLogs = mock(AWSLogs.class);
    when(mockAwsLogs.putLogEvents(any())).thenReturn(mockResult);

    final CloudWatchAppender appender = new CloudWatchAppender();
    appender.setContext(mockContext);
    appender.setAwsLogs(mockAwsLogs);
    appender.start();
    appender.doAppend(new LoggingEvent());
    appender.stop();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:18,代码来源:CloudWatchAppenderTest.java

示例3: testAlreadyExists

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void testAlreadyExists() {
    final Context mockContext = mock(Context.class);

    final PutLogEventsResult mockResult = mock(PutLogEventsResult.class);
    when(mockResult.getNextSequenceToken()).thenReturn("2");

    final AWSLogs mockAwsLogs = mock(AWSLogs.class);
    when(mockAwsLogs.createLogGroup(any())).thenThrow(ResourceAlreadyExistsException.class);
    when(mockAwsLogs.createLogStream(any())).thenThrow(ResourceAlreadyExistsException.class);
    when(mockAwsLogs.putLogEvents(any())).thenReturn(mockResult);

    final CloudWatchAppender appender = new CloudWatchAppender();
    appender.setContext(mockContext);
    appender.setAwsLogs(mockAwsLogs);
    appender.start();
    appender.doAppend(new LoggingEvent());
    appender.stop();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:20,代码来源:CloudWatchAppenderTest.java

示例4: append

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Override
protected void append(Object eventObject) {
    if (eventObject == null) {
        return;
    }
    if ( ! eventObject.getClass().isAssignableFrom(LoggingEvent.class) ) {
        return;
    }
    LoggingEvent event = (LoggingEvent) eventObject;
    String logEntry = event.getFormattedMessage();
    if (logEntry == null || logEntry.isEmpty()) {
        return;
    }
    int end = logEntry.indexOf("(");
    if (end > 0) {
        String methodName = logEntry.substring(0, end);
        if (ignoredConsoleEntries.contains(methodName)) {
            return;
        }
    }
    logEntries.add(logEntry);
}
 
开发者ID:webfolderio,项目名称:cdp4j,代码行数:23,代码来源:CdpAppender.java

示例5: testMEssagesStream

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void testMEssagesStream() {
	nifiAppender.start();
	int i = 0;
	boolean run=true;
	while (run) {
		LoggingEvent event = new LoggingEvent();
		event.setMessage("{\"message\":\"rest in peace for " + i + " \" }");
		nifiAppender.append(event);
		i++;
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if (i > 10)
			run=false;
	}
}
 
开发者ID:pradeepmvn,项目名称:logback-nifi-appender,代码行数:21,代码来源:TestNifiAppender.java

示例6: build

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
public static LoggingInfo build(LoggingEvent loggingEvent) {
	LoggingInfo loggingInfo = new LoggingInfo();
	if (null != loggingEvent) {
		loggingInfo.setMessage(loggingEvent.getMessage());
		loggingInfo.setLevel(loggingEvent.getLevel().toString());
		loggingInfo.setLoggerName(loggingEvent.getLoggerName());
		loggingInfo.setThreadName(loggingEvent.getThreadName());
		if (null != loggingEvent.getThrowableProxy()) {
			loggingInfo.setExceptionName(loggingEvent.getThrowableProxy().getClassName());
			loggingInfo.setExceptionMessage(loggingEvent.getThrowableProxy().getMessage());
			StackTraceElementProxy[] stackTraces = loggingEvent.getThrowableProxy().getStackTraceElementProxyArray();
			if (null != stackTraces && stackTraces.length > 0) {
				loggingInfo.setTopStackTrace(stackTraces[0].getStackTraceElement().toString());
			}
		}
		if (loggingEvent.hasCallerData()) {
			StackTraceElement st = loggingEvent.getCallerData()[0];
			loggingInfo.setCallerData(st.toString());
		}
		loggingInfo.setMdcProperty(loggingEvent.getMDCPropertyMap());
		loggingInfo.setCreateTime(millisecondToDateTime(loggingEvent.getTimeStamp()));
	}
	return loggingInfo;
}
 
开发者ID:Saisimon,项目名称:tip,代码行数:25,代码来源:LoggingInfo.java

示例7: shouldNotCaptureLogTentantAwareLogWhenEventLevelIsDifferentFromDeviceLevel

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void shouldNotCaptureLogTentantAwareLogWhenEventLevelIsDifferentFromDeviceLevel() {
    ILoggingEvent logEvent = new LoggingEvent(
            LOG.getName(),
            LOG,
            Level.DEBUG,
            "Test Message",
            null,
            new Object[]{device.toURI(), device.getLogLevel()}
    );

    konkerLoggerAppender.append(logEvent);
    Mockito.verify(konkerLoggerAppender, Mockito.never())
            .store(Mockito.any(),
                    Mockito.anyString(),
                    Mockito.anyString(),
                    Mockito.anyString());
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:19,代码来源:KonkerLoggerAppenderTest.java

示例8: shouldNotCaptureTenantAwareLogWhenEventHasNoURI

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void shouldNotCaptureTenantAwareLogWhenEventHasNoURI(){
    ILoggingEvent logEvent = new LoggingEvent(
            LOG.getName(),
            LOG,
            Level.DEBUG,
            "Test Message",
            null,
            new Object[]{device.getLogLevel()}
    );

    konkerLoggerAppender.append(logEvent);
    Mockito.verify(konkerLoggerAppender, Mockito.never())
            .store(Mockito.any(),
                    Mockito.anyString(),
                    Mockito.anyString(),
                    Mockito.anyString());
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:19,代码来源:KonkerLoggerAppenderTest.java

示例9: shouldNotCaptureTenantAwareLogWhenEventHasNoContextLogLevel

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void shouldNotCaptureTenantAwareLogWhenEventHasNoContextLogLevel(){
    ILoggingEvent logEvent = new LoggingEvent(
            LOG.getName(),
            LOG,
            Level.DEBUG,
            "Test Message",
            null,
            new Object[]{device.toURI()}
    );

    konkerLoggerAppender.append(logEvent);
    Mockito.verify(konkerLoggerAppender, Mockito.never())
            .store(Mockito.any(),
                    Mockito.anyString(),
                    Mockito.anyString(),
                    Mockito.anyString());
}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:19,代码来源:KonkerLoggerAppenderTest.java

示例10: shouldCaptureTenantAwareLog

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void shouldCaptureTenantAwareLog() {
    ILoggingEvent logEvent = new LoggingEvent(
            LOG.getName(),
            LOG,
            Level.INFO,
            "Test Message",
            null,
            new Object[]{device.toURI(), device.getLogLevel()}
            );

    konkerLoggerAppender.append(logEvent);
    Mockito.verify(konkerLoggerAppender, Mockito.atLeastOnce())
            .store(Mockito.any(),
                    Mockito.anyString(),
                    Mockito.anyString(),
                    Mockito.anyString());


}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:21,代码来源:KonkerLoggerAppenderTest.java

示例11: start_ShouldWaitAndLogUntilDatabaseIsAccessible

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void start_ShouldWaitAndLogUntilDatabaseIsAccessible() throws Exception {

    Connection mockConnection = mock(Connection.class);
    when(mockApplicationStartupDependentResource.getDatabaseConnection())
            .thenThrow(new SQLException("not there yet"))
            .thenReturn(mockConnection);

    applicationStartupDependentResourceChecker.checkAndWaitForResources();

    verify(mockApplicationStartupDependentResource, times(2)).getDatabaseConnection();
    verify(mockApplicationStartupDependentResource).sleep(5000L);

    verify(mockAppender, times(3)).doAppend(loggingEventArgumentCaptor.capture());
    List<LoggingEvent> allValues = loggingEventArgumentCaptor.getAllValues();

    assertThat(allValues.get(0).getFormattedMessage(), is("Checking for database availability >>>"));
    assertThat(allValues.get(1).getFormattedMessage(), is("Waiting for 5 seconds till the database is available ..."));
    assertThat(allValues.get(2).getFormattedMessage(), is("Database available."));
}
 
开发者ID:alphagov,项目名称:pay-adminusers,代码行数:21,代码来源:ApplicationStartupApplicationStartupDependentResourceCheckerTest.java

示例12: start_ShouldProgressivelyIncrementSleepingTimeBetweenChecksForDBAccessibility

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void start_ShouldProgressivelyIncrementSleepingTimeBetweenChecksForDBAccessibility() throws Exception {
    Connection mockConnection = mock(Connection.class);
    when(mockApplicationStartupDependentResource.getDatabaseConnection())
            .thenThrow(new SQLException("not there"))
            .thenThrow(new SQLException("not there yet"))
            .thenThrow(new SQLException("still not there"))
            .thenReturn(mockConnection);

    applicationStartupDependentResourceChecker.checkAndWaitForResources();

    verify(mockApplicationStartupDependentResource, times(4)).getDatabaseConnection();
    verify(mockApplicationStartupDependentResource).sleep(5000L);
    verify(mockApplicationStartupDependentResource).sleep(10000L);
    verify(mockApplicationStartupDependentResource).sleep(15000L);
    verify(mockAppender, times(5)).doAppend(loggingEventArgumentCaptor.capture());

    List<LoggingEvent> logStatement = loggingEventArgumentCaptor.getAllValues();
    assertThat(logStatement.get(0).getFormattedMessage(), is("Checking for database availability >>>"));
    assertThat(logStatement.get(1).getFormattedMessage(), is("Waiting for 5 seconds till the database is available ..."));
    assertThat(logStatement.get(2).getFormattedMessage(), is("Waiting for 10 seconds till the database is available ..."));
    assertThat(logStatement.get(3).getFormattedMessage(), is("Waiting for 15 seconds till the database is available ..."));
    assertThat(logStatement.get(4).getFormattedMessage(), is("Database available."));
}
 
开发者ID:alphagov,项目名称:pay-adminusers,代码行数:25,代码来源:ApplicationStartupApplicationStartupDependentResourceCheckerTest.java

示例13: addStatusEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Override
public void addStatusEvent(final Status status) {
    final Level level;
    switch (status.getLevel()) {
        case Status.INFO:
            level = Level.INFO;
            break;
        case Status.WARN:
            level = Level.WARN;
            break;
        case Status.ERROR:
            level = Level.ERROR;
            break;
        default:
            level = Level.INFO;
            break;
    }
    final LoggingEvent event = new LoggingEvent(StatusToFileListener.class.getSimpleName(),
            new LoggerContext().getLogger(StatusToFileListener.class),
            level,
            status.getMessage(),
            null,
            null);

    append(event);
}
 
开发者ID:napstr,项目名称:wolfia,代码行数:27,代码来源:StatusToFileListener.java

示例14: decide

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Override
public FilterReply decide(E eventObject) {
    if (!isStarted()) {
        return FilterReply.NEUTRAL;
    }

    LoggingEvent event = (LoggingEvent) eventObject;

    if (this.levelMin != null && !event.getLevel().isGreaterOrEqual(levelMin)) {
        return DENY;
    }

    if (this.levelMax != null && event.getLevel().toInt() > levelMax.toInt()) {
        return DENY;
    }

    if (acceptOnMatch) {
        return ACCEPT;
    } else {
        return NEUTRAL;
    }
}
 
开发者ID:Transkribus,项目名称:TranskribusCore,代码行数:23,代码来源:LevelRangeFilter.java

示例15: testBuildsMessage

import ch.qos.logback.classic.spi.LoggingEvent; //导入依赖的package包/类
@Test
public void testBuildsMessage() {
    AppenderForTest appender = new AppenderForTest();
    appender.setChannel("channel");
    appender.setUsername("username");
    appender.setIconEmoji("icon-emoji");
    appender.setIconUrl("icon-url");
    appender.setLinkNames(true);

    LoggingEvent event = new LoggingEvent();
    event.setMessage("text \"quoted\"");

    appender.append(event);

    String actual = new String(appender.body, StandardCharsets.UTF_8);
    String expected = "{ \"text\": \"text \\\"quoted\\\"\", \"channel\": \"channel\", \"username\": \"username\", \"icon_emoji\": \"icon-emoji\", \"icon_url\": \"icon-url\", \"link_names\": 1 }";
    Assert.assertEquals(expected, actual);
}
 
开发者ID:dwango,项目名称:slack-webhook-appender,代码行数:19,代码来源:SlackWebhookAppenderTest.java


注:本文中的ch.qos.logback.classic.spi.LoggingEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。