本文整理汇总了Java中ch.qos.logback.classic.BasicConfigurator类的典型用法代码示例。如果您正苦于以下问题:Java BasicConfigurator类的具体用法?Java BasicConfigurator怎么用?Java BasicConfigurator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicConfigurator类属于ch.qos.logback.classic包,在下文中一共展示了BasicConfigurator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: autoConfig
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
public void autoConfig() throws JoranException {
StatusListenerConfigHelper.installIfAsked(loggerContext);
URL url = findURLOfDefaultConfigurationFile(true);
if (url != null) {
configureByResource(url);
} else {
Configurator c = EnvUtil.loadFromServiceLoader(Configurator.class);
if (c != null) {
try {
c.setContext(loggerContext);
c.configure(loggerContext);
} catch (Exception e) {
throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader",
c != null ? c.getClass().getCanonicalName() : "null"), e);
}
} else {
BasicConfigurator.configure(loggerContext);
}
}
}
示例2: initLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
/**
* 加载logback配置
* @param location 文件路径
* @throws FileNotFoundException 文件不存在异常
*/
public static void initLogging(String location) throws FileNotFoundException {
if (LoggerFactory.getILoggerFactory() instanceof LoggerContext) {
String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
URL url = ResourceUtils.getURL(resolvedLocation);
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(loggerContext);
loggerContext.reset();
configurator.doConfigure(url);
} catch (Throwable e) {
BasicConfigurator.configureDefaultContext();
Logger log = LoggerFactory.getLogger(MODULE);
log.warn("Logback configure fail!", e);
}
}
}
示例3: initializeLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
private static void initializeLogging(Arguments arguments) {
//bootstrap depends on logback for logging console output. if the clientApplication does not want logback, they
//need to exclude logback from their project dependencies and initialize their own logging
try {
AppMain.class.getClassLoader().loadClass("ch.qos.logback.classic.LoggerContext");
} catch (ClassNotFoundException e) {
System.err.println("No Logback found in classpath. Skipping logging initialization. This is expected if you are configuring the logging system yourself. If you are not configuring logging yourself and would like to use logging provided by java-bootstrap, ensure that the Logback dependency jar exists in your classpath.");
return;
}
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.reset();
BasicConfigurator.configure(context);
ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
Level level = Level.valueOf(arguments.logLevel.name().toUpperCase());
logger.setLevel(level);
logger.info("Initialized logging at {} level", level);
}
示例4: initLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
protected LoggerContext initLogging() throws IOException {
LogManager.getLogManager().reset();
LogManager.getLogManager().readConfiguration();
LogManager.getLogManager().getLogger("").setLevel(java.util.logging.Level.INFO);
final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.reset();
BasicConfigurator configurator = new BasicConfigurator();
configurator.setContext(context);
configurator.configure(context);
context.getLogger(Logger.ROOT_LOGGER_NAME).setLevel(Level.INFO);
org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger();
org.slf4j.bridge.SLF4JBridgeHandler.install();
return context;
}
示例5: resetLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
@Before
public void resetLogging() {
LoggerContext loggerContext = ((Logger) LoggerFactory.getLogger(getClass()))
.getLoggerContext();
loggerContext.reset();
new BasicConfigurator().configure(loggerContext);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ConfigFileApplicationListenerTests.java
示例6: resetLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
@Before
public void resetLogging() {
LoggerContext loggerContext = ((Logger) LoggerFactory.getLogger(getClass()))
.getLoggerContext();
loggerContext.reset();
BasicConfigurator.configure(loggerContext);
}
示例7: addHandler
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
@Before
public void addHandler() throws Exception
{
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
serializedEvents.clear();
final OnConsoleStatusListener listener = new OnConsoleStatusListener();
listener.start();
context.getStatusManager().add(listener);
final JsonLogEncoder encoder = new JsonLogEncoder() {
@Override
public ObjectNode convertToObjectNode(ILoggingEvent event) {
ObjectNode node = super.convertToObjectNode(event);
serializedEvents.add(node);
return node;
}
};
encoder.setContext(context);
final UnsynchronizedAppenderBase<ILoggingEvent> captureAppender = new UnsynchronizedAppenderBase<ILoggingEvent>() {
@Override
protected void append(ILoggingEvent eventObject) {
encoder.encode(eventObject);
}
};
captureAppender.setContext(context);
captureAppender.start();
context.getLogger(Logger.ROOT_LOGGER_NAME).addAppender(captureAppender);
new BasicConfigurator().configure(context);
context.start();
}
示例8: reset
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
@After
public void reset() {
this.context.stop();
new BasicConfigurator()
.configure((LoggerContext) LoggerFactory.getILoggerFactory());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:SpringBootJoranConfiguratorTests.java
示例9: setUp
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
@Before
public void setUp() {
loggerContext.setName("LB139");
BasicConfigurator.configure(loggerContext);
}
示例10: configureDefaultLogging
import ch.qos.logback.classic.BasicConfigurator; //导入依赖的package包/类
protected void configureDefaultLogging() {
((LoggerContext) loggerFactory).reset();
// reset will cause log level to be set to debug, so we set it to something more useful
LogHelper.rootLogger().setLevel(Level.INFO);
new BasicConfigurator().configure((LoggerContext) loggerFactory);
}