本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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)));
}
示例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));
}
示例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()));
}
示例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();
}