本文整理匯總了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();
}