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


Java LoggingEvent.setLoggerName方法代碼示例

本文整理匯總了Java中ch.qos.logback.classic.spi.LoggingEvent.setLoggerName方法的典型用法代碼示例。如果您正苦於以下問題:Java LoggingEvent.setLoggerName方法的具體用法?Java LoggingEvent.setLoggerName怎麽用?Java LoggingEvent.setLoggerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.classic.spi.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.setLoggerName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: assertNeutral

import ch.qos.logback.classic.spi.LoggingEvent; //導入方法依賴的package包/類
private void assertNeutral(String logger, String loggerName, Boolean exclude) {
	LoggerFilter filter = create(loggerName, exclude);
	LoggingEvent event = new LoggingEvent();
	
	event.setLevel(Level.INFO);
	event.setLoggerName(logger);
	
	assertEquals(FilterReply.NEUTRAL, filter.decide(event));
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:10,代碼來源:LoggerFilterTest.java

示例6: assertDeny

import ch.qos.logback.classic.spi.LoggingEvent; //導入方法依賴的package包/類
private void assertDeny(String logger, String loggerName, Boolean exclude) {
	LoggerFilter filter = create(loggerName, exclude);
	LoggingEvent event = new LoggingEvent();
	
	event.setLevel(Level.INFO);
	event.setLoggerName(logger);
	
	assertEquals(FilterReply.DENY, filter.decide(event));
}
 
開發者ID:dstl,項目名稱:baleen,代碼行數:10,代碼來源:LoggerFilterTest.java

示例7: 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.setLoggerName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。