当前位置: 首页>>代码示例>>Java>>正文


Java BasicConfigurator类代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:ContextInitializer.java

示例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);
        }
    }
}
 
开发者ID:tryndamere,项目名称:bpm-adapter,代码行数:23,代码来源:LogbackConfigurer.java

示例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);
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:21,代码来源:AppMain.java

示例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;
}
 
开发者ID:eeichinger,项目名称:jcurl,代码行数:16,代码来源:JCurl.java

示例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);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:8,代码来源:ConfigFileEnvironmentPostProcessorTests.java

示例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();
}
 
开发者ID:opentable,项目名称:otj-logging,代码行数:35,代码来源:LogMetadataTest.java

示例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);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:6,代码来源:LB139_DeadlockTest.java

示例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);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:LogConfigurator.java


注:本文中的ch.qos.logback.classic.BasicConfigurator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。