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


Java LogService.getLogger方法代码示例

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


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

示例1: logEventShouldMatchCustomConfig

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void logEventShouldMatchCustomConfig() throws Exception {
  String logLogger = getClass().getName();
  Level logLevel = Level.DEBUG;
  String logMessage = "this is a log statement";

  Logger logger = LogService.getLogger();
  logger.debug(logMessage);

  BasicAppender appender = BasicAppender.getInstance();
  assertThat(appender).isNotNull();
  assertThat(appender.events()).hasSize(1);

  LogEvent event = appender.events().get(0);
  assertThat(event.getLoggerName()).isEqualTo(logLogger);
  assertThat(event.getLevel()).isEqualTo(logLevel);
  assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);

  assertThat(systemOutRule.getLog()).contains(logLevel.name());
  assertThat(systemOutRule.getLog()).contains(logMessage);
  assertThat(systemOutRule.getLog()).contains(CONFIG_LAYOUT_PREFIX);
  assertThat(systemOutRule.getLog()).matches(defineLogStatementRegex(logLevel, logMessage));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:CustomConfigWithLogServiceIntegrationTest.java

示例2: geodeVerboseShouldLogIfGeodeVerboseIsAccept

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void geodeVerboseShouldLogIfGeodeVerboseIsAccept() {
  configureLogging(this.configFileGeodeVerboseAccept);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEODE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).contains(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例3: geodeVerboseShouldNotLogIfGeodeVerboseIsDeny

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void geodeVerboseShouldNotLogIfGeodeVerboseIsDeny() {
  configureLogging(this.configFileGeodeVerboseDeny);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEODE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).doesNotContain(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例4: geodeVerboseShouldLogIfGemfireVerboseIsAccept

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void geodeVerboseShouldLogIfGemfireVerboseIsAccept() {
  configureLogging(this.configFileGemfireVerboseAccept);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEODE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).contains(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例5: geodeVerboseShouldNotLogIfGemfireVerboseIsDeny

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void geodeVerboseShouldNotLogIfGemfireVerboseIsDeny() {
  configureLogging(this.configFileGemfireVerboseDeny);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEODE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).doesNotContain(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例6: gemfireVerboseShouldNotLogIfGeodeVerboseIsAccept

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * GEMFIRE_VERBOSE is parent of GEODE_VERBOSE so enabling GEODE_VERBOSE does not enable
 * GEMFIRE_VERBOSE.
 */
@Test
public void gemfireVerboseShouldNotLogIfGeodeVerboseIsAccept() {
  configureLogging(this.configFileGeodeVerboseAccept);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEMFIRE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).doesNotContain(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例7: gemfireVerboseShouldLogIfGeodeVerboseIsDeny

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * GEMFIRE_VERBOSE is parent of GEODE_VERBOSE so disabling GEODE_VERBOSE does not disable
 * GEMFIRE_VERBOSE.
 */
@Test
public void gemfireVerboseShouldLogIfGeodeVerboseIsDeny() {
  configureLogging(this.configFileGeodeVerboseDeny);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEMFIRE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).contains(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:15,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例8: gemfireVerboseShouldLogIfGemfireVerboseIsAccept

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void gemfireVerboseShouldLogIfGemfireVerboseIsAccept() {
  configureLogging(this.configFileGemfireVerboseAccept);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEMFIRE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).contains(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例9: gemfireVerboseShouldNotLogIfGemfireVerboseIsDeny

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
@Test
public void gemfireVerboseShouldNotLogIfGemfireVerboseIsDeny() {
  configureLogging(this.configFileGemfireVerboseDeny);
  Logger logger = LogService.getLogger();

  String msg = this.testName.getMethodName();
  logger.info(LogMarker.GEMFIRE_VERBOSE, msg);

  assertThat(this.systemOutRule.getLog()).doesNotContain(msg);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:11,代码来源:GeodeVerboseLogMarkerIntegrationTest.java

示例10: setUpLogService

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
private void setUpLogService() throws Exception {
  // Load a base config and do some sanity checks
  writeSimpleConfigFile(this.configFile, Level.WARN);
  System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.configFileLocation);

  LogService.reconfigure();
  LogService.getLogger().getName(); // This causes the config file to be loaded
  this.logger = LogService.getLogger(TEST_LOGGER_NAME);
  this.appenderContext =
      ((org.apache.logging.log4j.core.Logger) LogService.getRootLogger()).getContext();

  assertThat(LogService.getLogger(LogService.BASE_LOGGER_NAME).getLevel(), is(Level.FATAL));
  assertThat(this.logger, is(instanceOf(FastLogger.class)));
  assertThat(this.logger.getLevel(), is(Level.WARN));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:16,代码来源:FastLoggerIntegrationJUnitTest.java

示例11: logServiceReturnsFastLoggers

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * LogService getLogger should return loggers wrapped in FastLogger
 */
@Test
public void logServiceReturnsFastLoggers() {
  this.logger = LogService.getLogger(TEST_LOGGER_NAME);

  assertThat(this.logger, is(instanceOf(FastLogger.class)));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:FastLoggerWithDefaultConfigJUnitTest.java

示例12: isDelegatingShouldBeFalse

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * FastLogger isDelegating should be false
 */
@Test
public void isDelegatingShouldBeFalse() {
  this.logger = LogService.getLogger(TEST_LOGGER_NAME);

  assertThat(((FastLogger) this.logger).isDelegating(), is(false));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:10,代码来源:FastLoggerWithDefaultConfigJUnitTest.java

示例13: testLogOutput

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * Verifies that writing to a Log4j logger will end up in the LogWriter's output.
 */
@Test
public final void testLogOutput() throws IOException {
  // Create the appender
  final StringWriter stringWriter = new StringWriter();
  final PureLogWriter logWriter =
      new PureLogWriter(InternalLogWriter.FINEST_LEVEL, new PrintWriter(stringWriter), "");

  final AppenderContext[] contexts = new AppenderContext[2];
  contexts[0] = LogService.getAppenderContext(); // root context
  contexts[1] = LogService.getAppenderContext(LogService.BASE_LOGGER_NAME); // "org.apache"
                                                                            // context

  this.appender =
      LogWriterAppender.create(contexts, LogService.MAIN_LOGGER_NAME, logWriter, null);

  final Logger logger = LogService.getLogger();

  // set the level to TRACE
  Configurator.setLevel(LogService.BASE_LOGGER_NAME, Level.TRACE);
  Configurator.setLevel(LogService.MAIN_LOGGER_NAME, Level.TRACE);

  assertEquals(Level.TRACE, logger.getLevel());

  logger.trace("TRACE MESSAGE");
  assertTrue(Pattern.compile(".*\\[finest .*TRACE MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logger.debug("DEBUG MESSAGE");
  assertTrue(Pattern.compile(".*\\[fine .*DEBUG MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logger.info("INFO MESSAGE");
  assertTrue(Pattern.compile(".*\\[info .*INFO MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logger.warn("ExpectedStrings: WARNING MESSAGE");
  assertTrue(Pattern.compile(".*\\[warning .*WARNING MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logger.error("ExpectedStrings: ERROR MESSAGE");
  assertTrue(Pattern.compile(".*\\[error .*ERROR MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logger.fatal("ExpectedStrings: FATAL MESSAGE");
  assertTrue(Pattern.compile(".*\\[severe .*FATAL MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  final Logger lowerLevelLogger =
      LogService.getLogger(LogService.BASE_LOGGER_NAME + ".subpackage");
  lowerLevelLogger.fatal("ExpectedStrings: FATAL MESSAGE");
  assertTrue(Pattern.compile(".*\\[severe .*FATAL MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  this.appender.destroy();
  assertFalse(Configurator.getLoggerConfig(LogService.BASE_LOGGER_NAME).getAppenders()
      .containsKey(this.appender.getName()));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:68,代码来源:LogWriterAppenderJUnitTest.java

示例14: testLogWriterLevels

import org.apache.geode.internal.logging.LogService; //导入方法依赖的package包/类
/**
 * Verifies that logging occurs at the levels set in the LogWriter
 */
@Test
public final void testLogWriterLevels() throws IOException {
  final String loggerName = LogService.MAIN_LOGGER_NAME; // this.getClass().getName();
  LogService.getLogger(); // Force logging to be initialized

  // Create the LogWriterLogger that will be attached to the appender
  final LogWriterLogger logWriterLogger = LogWriterLogger.create(loggerName, false);
  logWriterLogger.setLevel(Level.INFO);

  // Create the appender
  final StringWriter stringWriter = new StringWriter();
  final PureLogWriter logWriter =
      new PureLogWriter(InternalLogWriter.FINEST_LEVEL, new PrintWriter(stringWriter), "");

  final AppenderContext[] contexts = new AppenderContext[2];
  contexts[0] = LogService.getAppenderContext(); // root context
  contexts[1] = LogService.getAppenderContext(LogService.BASE_LOGGER_NAME); // "org.apache"
                                                                            // context

  this.appender = LogWriterAppender.create(contexts, loggerName, logWriter, null);

  logWriter.finest("DIRECT MESSAGE");
  assertTrue(Pattern.compile(".*\\[finest .*DIRECT MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  LogEvent event = Log4jLogEvent.newBuilder().setLevel(Level.INFO).setLoggerFqcn("NAME")
      .setLoggerName("NAME").setMessage(new ParameterizedMessage("LOGEVENT MESSAGE")).build();
  this.appender.append(event);
  assertTrue(Pattern.compile(".*\\[info .*LOGEVENT MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logWriterLogger.finest("FINEST MESSAGE");
  assertFalse(Pattern.compile(".*\\[finest .*FINEST MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logWriterLogger.fine("FINE MESSAGE");
  assertFalse(Pattern.compile(".*\\[fine .*FINE MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logWriterLogger.info("INFO MESSAGE");
  assertTrue(stringWriter.toString(),
      Pattern.compile(".*\\[info .*INFO MESSAGE.*", Pattern.DOTALL)
          .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  // Change the level
  logWriterLogger.setLevel(Level.DEBUG);

  logWriterLogger.finest("FINEST MESSAGE");
  assertFalse(Pattern.compile(".*\\[finest .*FINEST MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logWriterLogger.fine("FINE MESSAGE");
  assertTrue(Pattern.compile(".*\\[fine .*FINE MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  logWriterLogger.info("INFO MESSAGE");
  assertTrue(Pattern.compile(".*\\[info .*INFO MESSAGE.*", Pattern.DOTALL)
      .matcher(stringWriter.toString()).matches());
  stringWriter.getBuffer().setLength(0);

  this.appender.destroy();
}
 
开发者ID:ampool,项目名称:monarch,代码行数:73,代码来源:LogWriterAppenderJUnitTest.java


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