本文整理了Java中org.apache.logging.log4j.core.Logger.getLevel()
方法的一些代码示例,展示了Logger.getLevel()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.getLevel()
方法的具体详情如下:
包路径:org.apache.logging.log4j.core.Logger
类名称:Logger
方法名:getLevel
[英]Gets the Level associated with the Logger.
[中]获取与记录器关联的级别。
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLogger() throws Exception {
final Logger logger = this.ctx.getLogger(LOGGER_NAME);
assertThat(logger, is(instanceOf(org.apache.logging.log4j.core.Logger.class)));
final org.apache.logging.log4j.core.Logger l = (org.apache.logging.log4j.core.Logger) logger;
assertThat(l.getLevel(), is(equalTo(Level.DEBUG)));
assertThat(l.filterCount(), is(equalTo(1)));
final Iterator<Filter> iterator = l.getFilters();
assertThat(iterator.hasNext(), is(true));
final Filter filter = iterator.next();
assertThat(filter, is(instanceOf(ThreadContextMapFilter.class)));
final Map<String, Appender> appenders = l.getAppenders();
assertThat(appenders, is(notNullValue()));
assertThat(appenders.size(), is(equalTo(1)));
final Appender appender = appenders.get(APPENDER_NAME);
assertThat(appender, is(notNullValue()));
assertThat(appender.getName(), is(equalTo("STDOUT")));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLogger() throws Exception {
final Logger logger = this.ctx.getLogger(LOGGER_NAME);
assertThat(logger, is(instanceOf(org.apache.logging.log4j.core.Logger.class)));
final org.apache.logging.log4j.core.Logger l = (org.apache.logging.log4j.core.Logger) logger;
assertThat(l.getLevel(), is(equalTo(Level.DEBUG)));
assertThat(l.filterCount(), is(equalTo(1)));
final Iterator<Filter> iterator = l.getFilters();
assertThat(iterator.hasNext(), is(true));
final Filter filter = iterator.next();
assertThat(filter, is(instanceOf(ThreadContextMapFilter.class)));
final Map<String, Appender> appenders = l.getAppenders();
assertThat(appenders, is(notNullValue()));
assertThat(appenders, hasSize(1));
final Appender appender = appenders.get(APPENDER_NAME);
assertThat(appender, is(notNullValue()));
assertThat(appender.getName(), is(equalTo("STDOUT")));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLevelInheritence() throws Exception {
final Configuration config = context.getConfiguration();
final LoggerConfig loggerConfig = config.getLoggerConfig("org.apache.logging.log4j.core.LoggerTest");
assertNotNull(loggerConfig);
assertEquals(loggerConfig.getName(), "org.apache.logging.log4j.core.LoggerTest");
assertEquals(loggerConfig.getLevel(), Level.DEBUG);
final Logger localLogger = context.getLogger("org.apache.logging.log4j.core.LoggerTest");
assertTrue("Incorrect level - expected DEBUG, actual " + localLogger.getLevel(), localLogger.getLevel() == Level.DEBUG);
}
代码示例来源:origin: mulesoft/mule
@Override
public Level getLevel() {
return getLogger().getLevel();
}
代码示例来源:origin: org.apache.logging.log4j.adapters/log4j-1.2-api
public final Level getEffectiveLevel() {
final org.apache.logging.log4j.Level level = logger.getLevel();
switch (level) {
case TRACE:
return Level.TRACE;
case DEBUG:
return Level.DEBUG;
case INFO:
return Level.INFO;
case WARN:
return Level.WARN;
default:
return Level.ERROR;
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j12-api
public final Level getEffectiveLevel() {
org.apache.logging.log4j.Level level = logger.getLevel();
switch (level) {
case TRACE:
return Level.TRACE;
case DEBUG:
return Level.DEBUG;
case INFO:
return Level.INFO;
case WARN:
return Level.WARN;
default:
return Level.ERROR;
}
}
代码示例来源:origin: org.mule.modules/mule-module-launcher
@Override
public Level getLevel()
{
return getLogger().getLevel();
}
代码示例来源:origin: org.mule.runtime/mule-module-launcher
@Override
public Level getLevel() {
return getLogger().getLevel();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-1.2-api
public final Level getEffectiveLevel() {
switch (logger.getLevel().getStandardLevel()) {
case ALL:
return Level.ALL;
case TRACE:
return Level.TRACE;
case DEBUG:
return Level.DEBUG;
case INFO:
return Level.INFO;
case WARN:
return Level.WARN;
case ERROR:
return Level.ERROR;
case FATAL:
return Level.FATAL;
case OFF:
return Level.OFF;
default:
// TODO Should this be an IllegalStateException?
return Level.OFF;
}
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
/**
* This method is not exposed through the public API and is provided primarily for unit testing.
* <p>
* If the new level is null, this logger inherits the level from its parent.
* </p>
*
* @param level The Level to use on this Logger, may be null.
*/
public synchronized void setLevel(final Level level) {
if (level == getLevel()) {
return;
}
Level actualLevel;
if (level != null) {
actualLevel = level;
} else {
final Logger parent = getParent();
actualLevel = parent != null ? parent.getLevel() : privateConfig.loggerConfigLevel;
}
privateConfig = new PrivateConfig(privateConfig, actualLevel);
}
代码示例来源:origin: fbacchella/LogHub
@Override
public LogLevel getLogLevel() {
switch (parent.getLevel().getStandardLevel()) {
case ALL:
return LogLevel.ALL;
case TRACE:
return LogLevel.TRACE;
case DEBUG:
return LogLevel.DEBUG;
case INFO:
return LogLevel.INFO;
case WARN:
return LogLevel.WARN;
case ERROR:
return LogLevel.ERROR;
case FATAL:
return LogLevel.FATAL;
case OFF:
return LogLevel.OFF;
default:
return LogLevel.OFF;
}
}
代码示例来源:origin: ops4j/org.ops4j.pax.logging
/**
* Returns a String representation of this instance in the form {@code "name:level[ in context_name]"}.
*
* @return A String describing this Logger instance.
*/
@Override
public String toString() {
final String nameLevel = Strings.EMPTY + getName() + ':' + getLevel();
if (context == null) {
return nameLevel;
}
final String contextName = context.getName();
return contextName == null ? nameLevel : nameLevel + " in " + contextName;
}
代码示例来源:origin: spring-projects/spring-amqp
@BeforeAll
public static void setUp() {
Logger logger = (Logger) LogManager
.getLogger("org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer");
savedLevel = logger.getLevel();
logger.setLevel(Level.DEBUG);
}
代码示例来源:origin: apache/samza
@Test
public void test() {
String testLog = "testing";
Logger logger = (Logger) LogManager.getLogger(TestLoggingEventStringSerde.class);
LogEvent log = Log4jLogEvent.newBuilder()
.setLevel(logger.getLevel())
.setLoggerName(logger.getName())
.setMessage(new SimpleMessage(testLog))
.setThrown(null)
.build();
LoggingEventStringSerde loggingEventStringSerde = new LoggingEventStringSerde();
assertNull(loggingEventStringSerde.fromBytes(null));
assertNull(loggingEventStringSerde.toBytes(null));
assertArrayEquals(testLog.getBytes(), loggingEventStringSerde.toBytes(log));
// only the log messages are guaranteed to be equivalent
assertEquals(log.getMessage().toString(), loggingEventStringSerde.fromBytes(testLog.getBytes()).getMessage().toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!