本文整理汇总了Java中org.apache.logging.log4j.simple.SimpleLoggerContextFactory类的典型用法代码示例。如果您正苦于以下问题:Java SimpleLoggerContextFactory类的具体用法?Java SimpleLoggerContextFactory怎么用?Java SimpleLoggerContextFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleLoggerContextFactory类属于org.apache.logging.log4j.simple包,在下文中一共展示了SimpleLoggerContextFactory类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContexts
import org.apache.logging.log4j.simple.SimpleLoggerContextFactory; //导入依赖的package包/类
public static List<? extends LoggerContext> getContexts() {
LoggerContextFactory factory = org.apache.logging.log4j.LogManager.getFactory();
if(factory instanceof SimpleLoggerContextFactory) {
return Collections.singletonList(factory.getContext(null, null, null, true));
}
return ((Log4jContextFactory) org.apache.logging.log4j.LogManager.getFactory()).getSelector().getLoggerContexts();
}
示例2: getContext
import org.apache.logging.log4j.simple.SimpleLoggerContextFactory; //导入依赖的package包/类
/**
* Returns a LoggerContext.
*
* @param currentContext if false the LoggerContext appropriate for the caller of this method is returned. For
* example, in a web application if the caller is a class in WEB-INF/lib then one LoggerContext may be
* returned and if the caller is a class in the container's classpath then a different LoggerContext may
* be returned. If true then only a single LoggerContext will be returned.
* @return a LoggerContext.
*/
public static LoggerContext getContext(final boolean currentContext) {
// TODO: would it be a terrible idea to try and find the caller ClassLoader here?
try {
return factory.getContext(FQCN, null, null, currentContext, null, null);
} catch (final IllegalStateException ex) {
LOGGER.warn(ex.getMessage() + " Using SimpleLogger");
return new SimpleLoggerContextFactory().getContext(FQCN, null, null, currentContext, null, null);
}
}
示例3: beforeClass
import org.apache.logging.log4j.simple.SimpleLoggerContextFactory; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
System.setProperty(FACTORY_PROPERTY_NAME, SimpleLoggerContextFactory.class.getName());
}