本文整理汇总了Java中org.apache.logging.log4j.core.config.LoggerConfig.getLevel方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerConfig.getLevel方法的具体用法?Java LoggerConfig.getLevel怎么用?Java LoggerConfig.getLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.logging.log4j.core.config.LoggerConfig
的用法示例。
在下文中一共展示了LoggerConfig.getLevel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: watch
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public void watch(Class<?> loggerClass, Level level) {
this.loggerClass = loggerClass;
Appender appender = new AbstractAppender(APPENDER_NAME, null, PatternLayout.createDefaultLayout()) {
@Override
public void append(LogEvent event) {
logEvents.add(event);
}
};
appender.start();
final LoggerContext ctx = getLoggerContext();
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggerConfig(loggerClass.getName());
oldLevel = loggerConfig.getLevel();
loggerConfig.setLevel(level);
loggerConfig.addAppender(appender, level, null);
ctx.updateLoggers();
}
示例2: testReadException
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
/**
* Tests that {@link oc.io.base.DecoupledInputStream#read()} terminates
* normally when IOException is thrown in wrapped InputStream
*
* @throws IOException
*/
@Test
public void testReadException() throws IOException {
final byte b[] = new byte[1];
// Temporary disable logging for avoiding annoying Exception trace
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
final LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
final Level currentLevel = loggerConfig.getLevel();
loggerConfig.setLevel(Level.FATAL);
ctx.updateLoggers();
final TestInputStream testInputStream = new TestInputStream(new IOException(
"This exception is thrown due to a test scenario. This is expected behaviour"));
final DecoupledInputStream decInputStream = new DecoupledInputStream(testInputStream);
assertEquals(-1, decInputStream.read(b));
decInputStream.close();
loggerConfig.setLevel(currentLevel);
ctx.updateLoggers();
}
示例3: setLogLevel
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
@Override
public void setLogLevel(final String loggerName, final LogLevel logLevel) {
if (loggerContext != null) {
final Logger logger = loggerContext.getLogger(loggerName);
final LoggerConfig config = logger.get();
final Level level = convert(logLevel);
if (config.getLevel() != level) {
config.setLevel(level);
}
}
}
示例4: updateLevel
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
private static void updateLevel(Level level) {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
Level curLevel = loggerConfig.getLevel();
if (curLevel != level) {
loggerConfig.setLevel(level);
ctx.updateLoggers();
}
}
示例5: loff
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
protected void loff() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(ClientCnxn.class.getName());
cxnLevel = loggerConfig.getLevel();
loggerConfig.setLevel(Level.ERROR);
ctx.updateLoggers();
}
示例6: setLogLevel
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static void setLogLevel(Level NewLevel)
{
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
Level OldLevel = loggerConfig.getLevel();
if (OldLevel != NewLevel)
{
loggerConfig.setLevel(NewLevel);
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
}
if (_originalLogLevel == null)
_originalLogLevel = OldLevel;
}
示例7: addRootApender
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
/**
* Adds the specified appender to the root logger.
*
* @param appender
* the appender
* @param level
* the logging level to assign to the appender. Default is INFO
*/
public static synchronized void addRootApender(Appender appender, String level) {
Configuration config = getConfiguration();
appender.start();
config.addAppender(appender);
Level l = Level.toLevel(level, Level.INFO);
LoggerConfig root = config.getRootLogger();
if (!root.getLevel().isLessSpecificThan(l)) {
if (originalRootLevel == null) {
originalRootLevel = root.getLevel();
Iterator<AppenderRef> it = root.getAppenderRefs().iterator();
while (it.hasNext()) {
AppenderRef ar = it.next();
if (ar.getLevel() == null) {
Appender a = root.getAppenders().get(ar.getRef());
root.removeAppender(a.getName());
root.addAppender(a, originalRootLevel, ar.getFilter());
}
}
}
root.setLevel(l);
}
root.addAppender(appender, l, null);
addedAppenders++;
getContext().updateLoggers();
}
示例8: PrivateConfig
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public PrivateConfig(final PrivateConfig pc, final LoggerConfig lc) {
this.config = pc.config;
this.loggerConfig = lc;
this.level = lc.getLevel();
this.intLevel = this.level.intLevel();
this.logger = pc.logger;
}
示例9: PrivateConfig
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public PrivateConfig(final PrivateConfig pc, final LoggerConfig lc) {
this.config = pc.config;
this.loggerConfig = lc;
this.loggerConfigLevel = lc.getLevel();
this.intLevel = this.loggerConfigLevel.intLevel();
this.logger = pc.logger;
}
示例10: getLevel
import org.apache.logging.log4j.core.config.LoggerConfig; //导入方法依赖的package包/类
public static Level getLevel(String name) {
LoggerConfig logConfig = getOrCreateLoggerConfig(name);
return logConfig.getLevel();
}