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


Java LevelChangePropagator.setResetJUL方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.jul.LevelChangePropagator.setResetJUL方法的典型用法代码示例。如果您正苦于以下问题:Java LevelChangePropagator.setResetJUL方法的具体用法?Java LevelChangePropagator.setResetJUL怎么用?Java LevelChangePropagator.setResetJUL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.jul.LevelChangePropagator的用法示例。


在下文中一共展示了LevelChangePropagator.setResetJUL方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installJulBridge

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
private void installJulBridge() {
  // Workaround for strange ClassCircularityErrors in the JUL bridge when very
  // strange classloader hierarchies are
  // set up and logging occurs from inside classloaders themselves (eg: some
  // strange Tomcat deployments)
  try {
    Class.forName("java.util.logging.LogRecord");
  } catch (ClassNotFoundException e) {
    throw new AssertionError(e);
  }

  LoggerContext loggerContext = (LoggerContext) getContext();

  if (!SLF4JBridgeHandler.isInstalled()) {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
  }
  LevelChangePropagator julLevelChanger = new LevelChangePropagator();
  julLevelChanger.setContext(loggerContext);
  julLevelChanger.setResetJUL(true);
  julLevelChanger.start();
  loggerContext.addListener(julLevelChanger);
}
 
开发者ID:irenical,项目名称:jindy,代码行数:24,代码来源:LoggerConfigurator.java

示例2: configureLevels

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
private Logger configureLevels() {

        final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
        root.getLoggerContext().reset();

        final LevelChangePropagator propagator = new LevelChangePropagator();
        propagator.setContext(root.getLoggerContext());
        propagator.setResetJUL(true);

        root.getLoggerContext().addListener(propagator);

        root.setLevel(config.getLevel());

        // Decode the packages and levels
        for (Map.Entry<String, Level> entry : config.getLoggers().entrySet()) {
            ((Logger) LoggerFactory.getLogger(entry.getKey())).setLevel(entry.getValue());
        }

        return root;
    }
 
开发者ID:bither,项目名称:bither-desktop-java,代码行数:21,代码来源:LoggingFactory.java

示例3: configLogbackContext

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
protected void configLogbackContext(LoggerContext context, Logger root, Map<String, LoggerFactory> loggers) {
    context.reset();

    if (debugLogback) {
        StatusListenerConfigHelper.addOnConsoleListenerInstance(context, new OnConsoleStatusListener());
    }

    LevelChangePropagator propagator = new LevelChangePropagator();
    propagator.setContext(context);
    propagator.setResetJUL(true);

    context.addListener(propagator);

    root.setLevel(Level.toLevel(level.name(), Level.INFO));

    loggers.forEach((name, lf) -> lf.configLogger(name, context));

    if (appenders.isEmpty()) {
        setAppenders(Collections.singletonList(new ConsoleAppenderFactory()));
    }

    appenders.forEach(a -> root.addAppender(a.createAppender(context, getLogFormat())));
}
 
开发者ID:bootique,项目名称:bootique-logback,代码行数:24,代码来源:LogbackContextFactory.java

示例4: configureLevels

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
private Logger configureLevels() {
    final Logger root = (Logger) LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    root.getLoggerContext().reset();

    final LevelChangePropagator propagator = new LevelChangePropagator();
    propagator.setContext(root.getLoggerContext());
    propagator.setResetJUL(true);

    root.getLoggerContext().addListener(propagator);

    root.setLevel(config.getServerLogConfiguration().getRootLevel());

    for (Map.Entry<String, Level> entry : config.getServerLogConfiguration().getLoggers().entrySet()) {
        ((Logger) LoggerFactory.getLogger(entry.getKey())).setLevel(entry.getValue());
    }

    return root;
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:19,代码来源:ServerLoggingFactory.java

示例5: configureLogging

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
/**
 * Configure logging.
 * @param loggingSettings the logging settings
 */
public void configureLogging(final LoggingSettings loggingSettings) {

    final Logger root = (Logger)LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
    final LoggerContext context = root.getLoggerContext();

    // Reset prior configuration
    context.reset();

    // Propagate level changes to java.util.logging
    final LevelChangePropagator propagator = new LevelChangePropagator();
    propagator.setContext(context);
    propagator.setResetJUL(true);

    // Set base threshold for all other loggers.
    root.setLevel(loggingSettings.getLevel());

    // Loop through explicitly configured loggers and set the levels
    for (final Map.Entry<String, Level> entry : loggingSettings.getLoggers().entrySet()) {
        ((Logger)LoggerFactory.getLogger(entry.getKey())).setLevel(entry.getValue());
    }

    if (loggingSettings.getLogFile().isEnabled()) {
        root.addAppender(getFileAppender(loggingSettings.getLogFile(), context));
    }

    if (loggingSettings.getConsole().isEnabled()) {
        root.addAppender(getConsoleAppender(loggingSettings.getConsole(), context));
    }
}
 
开发者ID:Metrink,项目名称:croquet,代码行数:34,代码来源:CroquetLoggingFactory.java

示例6: configureLogging

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
private static void configureLogging(File logFile, Level level) {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    OutputStreamAppender<ILoggingEvent> appender;
    if (logFile == null) {
        appender = configureConsoleLogging(loggerContext);
    } else {
        appender = configureFileLogging(logFile, loggerContext);
    }
    System.out.println("Logging: The log level is set to " + level);
    PatternLayoutEncoder patternLayoutEncoder = new PatternLayoutEncoder();
    patternLayoutEncoder.setPattern(LogDescription.LOG_PATTERN);
    patternLayoutEncoder.setContext(loggerContext);
    patternLayoutEncoder.start();
    appender.setEncoder(patternLayoutEncoder);
    appender.start();
    ch.qos.logback.classic.Logger rootLogger = loggerContext.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    loggerContext.stop();
    rootLogger.detachAndStopAllAppenders();
    rootLogger.addAppender(appender);
    rootLogger.setLevel(level);
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    LevelChangePropagator levelChangePropagator = new LevelChangePropagator();
    levelChangePropagator.setResetJUL(true);
    levelChangePropagator.setContext(loggerContext);
    levelChangePropagator.start();
    loggerContext.addListener(levelChangePropagator);
    loggerContext.start();
}
 
开发者ID:documents4j,项目名称:documents4j,代码行数:30,代码来源:StandaloneClient.java

示例7: addLevelChangePropagator

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
private void addLevelChangePropagator(LoggerContext loggerContext) {
	LevelChangePropagator levelChangePropagator = new LevelChangePropagator();
	levelChangePropagator.setResetJUL(true);
	levelChangePropagator.setContext(loggerContext);
	loggerContext.addListener(levelChangePropagator);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:LogbackLoggingSystem.java

示例8: environmentPrepared

import ch.qos.logback.classic.jul.LevelChangePropagator; //导入方法依赖的package包/类
@Override
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
public void environmentPrepared(ConfigurableEnvironment env) {
    this.buildInitializer(DefaultLoggingInitializer::new).initialize(env);

    this.loggerContext = ContextSelectorStaticBinder.getSingleton().getContextSelector().getDefaultLoggerContext();

    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();

    this.loggerContext.stop();
    this.loggerContext.reset();

    LevelChangePropagator lvlChangePropagator = new LevelChangePropagator();
    lvlChangePropagator.setContext(this.loggerContext);
    lvlChangePropagator.setResetJUL(true);
    this.loggerContext.addListener(lvlChangePropagator);

    this.loggerContext.putObject(SdcctApplication.BEAN_NAME, this.app);

    this.buildConversionRule(MessageMarkerConverter.WORD, MessageMarkerConverter.class);
    this.buildConversionRule(PriorityColorCompositeConverter.WORD, PriorityColorCompositeConverter.class);
    this.buildConversionRule(RootCauseThrowableProxyConverter.WORD, RootCauseThrowableProxyConverter.class);
    this.buildConversionRule(ThreadSectionConverter.WORD, ThreadSectionConverter.class);
    this.buildConversionRule(TxMdcConverter.WORD, TxMdcConverter.class);

    this.buildAppender(new ConsoleAppender<>(), AppenderType.CONSOLE, this.buildPatternLayoutEncoder(CONSOLE_APPENDER_PATTERN), true);

    this.buildFileAppender(AppenderType.FILE, this.buildPatternLayoutEncoder(FILE_APPENDER_PATTERN), new File(
        (this.logFileDir = this.app.getLogFileDirectory()), (this.app.getLogFileName() + FilenameUtils.EXTENSION_SEPARATOR + SdcctFileNameExtensions.LOG)));

    this.buildCachingAppender(AppenderType.LOGSTASH_FILE);

    this.buildLogger(org.slf4j.Logger.ROOT_LOGGER_NAME, Level.WARN, true, this.appenders.values());

    PropertySourceUtils.getSubProperties(env.getPropertySources(), SdcctPropertyNames.LOGGING_LOGGER_PREFIX).forEach((loggerName, loggerPropValue) -> {
        String[] loggerPropValueParts = StringUtils.split(((String) loggerPropValue), SdcctStringUtils.COLON, 2);
        Level loggerLvl = Level.toLevel(loggerPropValueParts[0].toUpperCase(), null);

        if (loggerLvl == null) {
            throw new ApplicationContextException(
                String.format("Unknown application (name=%s) logger (name=%s) level: %s", this.app.getName(), loggerName, loggerPropValueParts[0]));
        }

        this.buildLogger(loggerName, loggerLvl, false, ((loggerPropValueParts.length == 2)
            ? Stream.of(org.springframework.util.StringUtils.commaDelimitedListToStringArray(loggerPropValueParts[1])).map(loggerAppenderName -> {
                AppenderType loggerAppenderType = SdcctEnumUtils.findById(AppenderType.class, loggerAppenderName);

                if (!this.appenders.containsKey(loggerAppenderType)) {
                    throw new ApplicationContextException(String.format("Unknown application (name=%s) logger (name=%s) appender type (name=%s).",
                        this.app.getName(), loggerName, loggerAppenderName));
                }

                return this.appenders.get(loggerAppenderType);
            }).collect(Collectors.toList()) : this.appenders.values()));
    });

    StatusManager statusManager = this.loggerContext.getStatusManager();
    StatusUtil statusUtil = new StatusUtil(statusManager);
    long lastResetTime = statusUtil.timeOfLastReset();

    if (statusUtil.getHighestLevel(lastResetTime) >= Status.WARN) {
        StatusPrinter.print(statusManager, lastResetTime);

        throw new ApplicationContextException(String.format("Unable to initialize application (name=%s) logging.", this.app.getName()));
    }

    this.loggerContext.getLogger(LoggingInitializerRunListener.class).info(String.format("Application (name=%s) logging initialized.", this.app.getName()));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:70,代码来源:LoggingInitializerRunListener.java


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