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


Java LoggingEvent.setTimeStamp方法代码示例

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


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

示例1: ignoreDefaultLocale

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void ignoreDefaultLocale() {
  Locale originalDefaultLocale = Locale.getDefault();
  Locale.setDefault(Locale.TRADITIONAL_CHINESE);

  try {
    converter.start();

    LoggingEvent le = createLoggingEvent();
    calendar.set(2012, Calendar.OCTOBER, 11, 22, 14, 15);
    le.setTimeStamp(calendar.getTimeInMillis());
    String result = converter.convert(le);
    assertEquals("<191>Oct 11 22:14:15 " + HOSTNAME + " ", result);
  } finally {
    Locale.setDefault(originalDefaultLocale);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:SyslogStartConverterTest.java

示例2: build

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public LoggingEvent build(int i) {

    LoggingEvent le = new LoggingEvent();
    le.setTimeStamp(System.currentTimeMillis());

    Object[] aa = new Object[] { i, "HELLO WORLD [========== ]" + i };

    le.setArgumentArray(aa);
    String msg = MSG + i;
    le.setMessage(msg);

    // compute formatted message
    // this forces le.formmatedMessage to be set (this is the whole point of the
    // exercise)
    le.getFormattedMessage();
    le.setLevel(Level.DEBUG);
    le.setLoggerName(logger.getName());
    le.setLoggerContextRemoteView(loggerContext.getLoggerContextRemoteView());
    le.setThreadName("threadName");
    return le;
  }
 
开发者ID:cscfa,项目名称:bartleby,代码行数:22,代码来源:LoggingEventWithParametersBuilder.java

示例3: testWholeCycle

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void testWholeCycle() throws JoranException {
  String mdcKey = "cycle";
  configure(SIFT_FOLDER_PREFIX + "completeCycle.xml");
  MDC.put(mdcKey, "a");
  logger.debug("smoke");
  long timestamp = System.currentTimeMillis();
  SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
  ListAppender<ILoggingEvent> listAppender = (ListAppender<ILoggingEvent>)
          sa.getAppenderTracker().find("a");
  assertNotNull(listAppender);
  List<ILoggingEvent> eventList = listAppender.list;
  assertEquals(1, listAppender.list.size());
  assertEquals("smoke", eventList.get(0).getMessage());

  MDC.remove(mdcKey);
  LoggingEvent le = new LoggingEvent("x", logger, Level.INFO, "hello", null,
          null);
  le.setTimeStamp(timestamp + ComponentTracker.DEFAULT_TIMEOUT + 1);
  sa.doAppend(le);
  assertFalse(listAppender.isStarted());
  assertEquals(1, sa.getAppenderTracker().allKeys().size());
  assertTrue(sa.getAppenderTracker().allKeys().contains("cycleDefault"));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:25,代码来源:SiftingAppenderTest.java

示例4: maxAppendersCountPropertyShouldBeHonored

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void maxAppendersCountPropertyShouldBeHonored() throws JoranException {
  configure(SIFT_FOLDER_PREFIX + "maxAppenderCount.xml");
  int max = 5;
  SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");
  String mdcKey = "max";
  for(int i = 0; i <= max; i++) {
    MDC.put(mdcKey, "" + (diff + i));
    LoggingEvent event = new LoggingEvent("", logger, Level.DEBUG, "max"+i, null, null);
    event.setTimeStamp(now);
    sa.doAppend(event);
    now += AbstractComponentTracker.WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS;
  }
  AppenderTracker<ILoggingEvent> tracker = sa.getAppenderTracker();
  assertEquals(max, tracker.allKeys().size());
  assertNull(tracker.find("" + (diff + 0)));
  for(int i = 1; i <= max; i++) {
    assertNotNull(tracker.find("" + (diff + i)));
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:SiftingAppenderTest.java

示例5: timeoutPropertyShouldBeHonored

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void timeoutPropertyShouldBeHonored() throws JoranException, InterruptedException {
  configure(SIFT_FOLDER_PREFIX + "timeout.xml");
  long timeout = 30*1000;
  SiftingAppender sa = (SiftingAppender) root.getAppender("SIFT");

  LoggingEvent event = new LoggingEvent("", logger, Level.DEBUG, "timeout", null, null);
  event.setTimeStamp(now);
  sa.doAppend(event);

  AppenderTracker<ILoggingEvent> tracker = sa.getAppenderTracker();

  assertEquals(1, tracker.getComponentCount());

  now += timeout+1;
  tracker.removeStaleComponents(now);
  assertEquals(0, tracker.getComponentCount());
  statusChecker.assertIsErrorFree();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:20,代码来源:SiftingAppenderTest.java

示例6: makeEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private LoggingEvent makeEvent(Level level, String message, Throwable th) {
	LoggingEvent event = new LoggingEvent();
	event.setLoggerName(CloudWatchAppender.class.getName());
	event.setLevel(level);
	event.setMessage(message);
	event.setTimeStamp(System.currentTimeMillis());
	if (th != null) {
		event.setThrowableProxy(new ThrowableProxy(th));
	}
	return event;
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:12,代码来源:CloudWatchAppender.java

示例7: onLog

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
public void onLog(LogEntry logEntry) {

  final LoggingEvent loggingEvent = new LoggingEvent();
  loggingEvent.setTimeStamp(logEntry.getTimestamp());
  loggingEvent.setLoggerName(logEntry.getLoggerName());
  loggingEvent.setLevel(Level.valueOf(logEntry.getLogLevel().name()));
  loggingEvent.setThreadName(logEntry.getThreadName());
  Object [] formatObjects = new Object[] {logEntry.getHost(),
    getSimpleClassName(logEntry.getSourceClassName()),
    logEntry.getSourceMethodName(),
    logEntry.getFileName(),
    logEntry.getLineNumber(),logEntry.getMessage()};
  loggingEvent.setMessage(MESSAGE_FORMAT.get().format(formatObjects));

  // Prints the throwable and stack trace.
  LogThrowable logThrowable = logEntry.getThrowable();
  if (logThrowable != null) {
    loggingEvent.setThrowableProxy(new ThrowableProxy(setThrowable(logThrowable)));
  }

  if (logger instanceof Logger) {
    ((Logger) logger).callAppenders(loggingEvent);
  } else {
    logger.info("Logger is not instance of ch.qos.logback.classic.Logger. Logger event is: {}", loggingEvent);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:28,代码来源:YarnTwillLogHandler.java

示例8: datesLessThanTen

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void datesLessThanTen() {
  // RFC 3164, section 4.1.2:
  // If the day of the month is less than 10, then it MUST be represented as
  // a space and then the number.  For example, the 7th day of August would be
  // represented as "Aug  7", with two spaces between the "g" and the "7".
  LoggingEvent le = createLoggingEvent();
  calendar.set(2012, Calendar.AUGUST, 7, 13, 15, 0);
  le.setTimeStamp(calendar.getTimeInMillis());
  assertEquals("<191>Aug  7 13:15:00 " + HOSTNAME + " ", converter.convert(le));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:12,代码来源:SyslogStartConverterTest.java

示例9: datesGreaterThanTen

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void datesGreaterThanTen() {
  LoggingEvent le = createLoggingEvent();
  calendar.set(2012, Calendar.OCTOBER, 11, 22, 14, 15);
  le.setTimeStamp(calendar.getTimeInMillis());
  assertEquals("<191>Oct 11 22:14:15 " + HOSTNAME + " ", converter.convert(le));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:8,代码来源:SyslogStartConverterTest.java

示例10: multipleConversions

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
public void multipleConversions() {
  LoggingEvent le = createLoggingEvent();
  calendar.set(2012, Calendar.OCTOBER, 11, 22, 14, 15);
  le.setTimeStamp(calendar.getTimeInMillis());
  assertEquals("<191>Oct 11 22:14:15 " + HOSTNAME + " ", converter.convert(le));
  assertEquals("<191>Oct 11 22:14:15 " + HOSTNAME + " ", converter.convert(le));

  calendar.set(2012, Calendar.OCTOBER, 11, 22, 14, 16);
  le.setTimeStamp(calendar.getTimeInMillis());
  assertEquals("<191>Oct 11 22:14:16 " + HOSTNAME + " ", converter.convert(le));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:13,代码来源:SyslogStartConverterTest.java

示例11: hostnameShouldNotIncludeDomain

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test
@Ignore
public void hostnameShouldNotIncludeDomain() throws Exception {
  // RFC 3164, section 4.1.2:
  // The Domain Name MUST NOT be included in the HOSTNAME field.
  String host = HOSTNAME;
  final int firstPeriod = host.indexOf(".");
  if (firstPeriod != -1) {
    host = host.substring(0, firstPeriod);
  }
  LoggingEvent le = createLoggingEvent();
  calendar.set(2012, Calendar.OCTOBER, 11, 22, 14, 15);
  le.setTimeStamp(calendar.getTimeInMillis());
  assertEquals("<191>Oct 11 22:14:15 " + host + " ", converter.convert(le));
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:16,代码来源:SyslogStartConverterTest.java

示例12: build

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
public Object build(int i) {
  LoggingEvent le = new LoggingEvent();
  le.setTimeStamp(System.currentTimeMillis());
  le.setLevel(Level.DEBUG);
  le.setLoggerName(logger.getName());
  le.setLoggerContextRemoteView(loggerContext.getLoggerContextRemoteView());
  le.setMessage(MSG_PREFIX);
  le.setThreadName("threadName");
  return le;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:11,代码来源:TrivialLoggingEventBuilder.java

示例13: createLoggingEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
private ILoggingEvent createLoggingEvent() {
  LoggingEvent le = new LoggingEvent();
  le.setLevel(Level.DEBUG);
  le.setMessage("test message");
  le.setTimeStamp(System.currentTimeMillis());
  le.setThreadName(Thread.currentThread().getName());
  return le;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:9,代码来源:JMSQueueAppenderTest.java

示例14: newEvent

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Override
protected Object newEvent(LogDetails logDetails) {
    ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(logDetails.getClassName());
    LoggingEvent event = new LoggingEvent(this.getClass().getName(), logger, Level.DEBUG, logDetails.getLogMessage(),
            logDetails.getException(), null);
    event.setThreadName(logDetails.getThreadName());
    event.setTimeStamp(logDetails.getTimeMillis());
    event.setMDCPropertyMap(logDetails.getMdc());
    StackTraceElement callerData = new StackTraceElement(logDetails.getClassName(), logDetails.getMethodName(),
            logDetails.getFileName(), logDetails.getLineNumber());
    event.setCallerData(new StackTraceElement[] { callerData });
    return event;
}
 
开发者ID:Talend,项目名称:daikon,代码行数:14,代码来源:LogBackJSONLayoutTest.java

示例15: testBasic

import ch.qos.logback.classic.spi.LoggingEvent; //导入方法依赖的package包/类
@Test(timeout = 5000)
public void testBasic() throws InterruptedException {
	CloudWatchAppender appender = new CloudWatchAppender();
	AWSLogsClient awsLogClient = createMock(AWSLogsClient.class);
	appender.setAwsLogsClient(awsLogClient);

	appender.setMaxBatchSize(1);
	appender.setRegion("region");
	final String logGroup = "pfqoejpfqe";
	appender.setLogGroup(logGroup);
	final String logStream = "pffqjfqjpoqoejpfqe";
	appender.setLogStream(logStream);
	PatternLayout layout = new PatternLayout();
	layout.setContext(new LoggerContext());
	layout.setPattern("[%thread] %level %logger{20} - %msg%n%xThrowable");
	layout.start();
	appender.setLayout(layout);

	LoggingEvent event = new LoggingEvent();
	event.setTimeStamp(System.currentTimeMillis());
	String loggerName = "name";
	event.setLoggerName(loggerName);
	Level level = Level.DEBUG;
	event.setLevel(level);
	String message = "fjpewjfpewjfpewjfepowf";
	event.setMessage(message);

	String threadName = Thread.currentThread().getName();
	final String fullMessage = "[" + threadName + "] " + level + " " + loggerName + " - " + message + "\n";

	final PutLogEventsResult result = new PutLogEventsResult();
	String sequence = "ewopjfewfj";
	result.setNextSequenceToken(sequence);
	expect(awsLogClient.putLogEvents(isA(PutLogEventsRequest.class))).andAnswer(new IAnswer<PutLogEventsResult>() {
		@Override
		public PutLogEventsResult answer() {
			PutLogEventsRequest request = (PutLogEventsRequest) getCurrentArguments()[0];
			assertEquals(logGroup, request.getLogGroupName());
			assertEquals(logStream, request.getLogStreamName());
			List<InputLogEvent> events = request.getLogEvents();
			assertEquals(1, events.size());
			assertEquals(fullMessage, events.get(0).getMessage());
			return result;
		}
	}).times(2);
	awsLogClient.shutdown();

	// =====================================

	replay(awsLogClient);
	appender.start();
	// for coverage
	appender.start();
	appender.append(event);
	Thread.sleep(10);
	appender.append(event);
	while (appender.getEventsWrittenCount() < 2) {
		Thread.sleep(10);
	}
	appender.stop();
	verify(awsLogClient);
}
 
开发者ID:j256,项目名称:cloudwatch-logback-appender,代码行数:63,代码来源:CloudWatchAppenderTest.java


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